diff --git a/src/box/gc.c b/src/box/gc.c index e8074078ebf01de7e1614258d609ac81de319666..6a7e371f9d57145fc07cc3615aaad063d495bfb9 100644 --- a/src/box/gc.c +++ b/src/box/gc.c @@ -355,7 +355,7 @@ static int gc_do_checkpoint(void) { int rc; - struct vclock vclock; + struct wal_checkpoint checkpoint; assert(!gc.checkpoint_is_in_progress); gc.checkpoint_is_in_progress = true; @@ -373,19 +373,19 @@ gc_do_checkpoint(void) rc = engine_begin_checkpoint(); if (rc != 0) goto out; - rc = wal_begin_checkpoint(&vclock); + rc = wal_begin_checkpoint(&checkpoint); if (rc != 0) goto out; - rc = engine_commit_checkpoint(&vclock); + rc = engine_commit_checkpoint(&checkpoint.vclock); if (rc != 0) goto out; - wal_commit_checkpoint(&vclock); + wal_commit_checkpoint(&checkpoint); /* * Finally, track the newly created checkpoint in the garbage * collector state. */ - gc_add_checkpoint(&vclock); + gc_add_checkpoint(&checkpoint.vclock); out: if (rc != 0) engine_abort_checkpoint(); diff --git a/src/box/wal.c b/src/box/wal.c index 644f58c84326c7ba062058dbe74e69535e2fcabf..8e56e6aeb2ca79670698a2c8d9ee740ec7bd6c70 100644 --- a/src/box/wal.c +++ b/src/box/wal.c @@ -497,12 +497,6 @@ wal_sync(void) cbus_flush(&wal_thread.wal_pipe, &wal_thread.tx_prio_pipe, NULL); } -struct wal_checkpoint -{ - struct cbus_call_msg base; - struct vclock vclock; -}; - static int wal_begin_checkpoint_f(struct cbus_call_msg *data) { @@ -534,11 +528,11 @@ wal_begin_checkpoint_f(struct cbus_call_msg *data) } int -wal_begin_checkpoint(struct vclock *vclock) +wal_begin_checkpoint(struct wal_checkpoint *checkpoint) { struct wal_writer *writer = &wal_writer_singleton; if (writer->wal_mode == WAL_NONE) { - vclock_copy(vclock, &writer->vclock); + vclock_copy(&checkpoint->vclock, &writer->vclock); return 0; } if (!stailq_empty(&writer->rollback)) { @@ -552,15 +546,13 @@ wal_begin_checkpoint(struct vclock *vclock) diag_set(ClientError, ER_CHECKPOINT_ROLLBACK); return -1; } - struct wal_checkpoint msg; bool cancellable = fiber_set_cancellable(false); int rc = cbus_call(&wal_thread.wal_pipe, &wal_thread.tx_prio_pipe, - &msg.base, wal_begin_checkpoint_f, NULL, + &checkpoint->base, wal_begin_checkpoint_f, NULL, TIMEOUT_INFINITY); fiber_set_cancellable(cancellable); if (rc != 0) return -1; - vclock_copy(vclock, &msg.vclock); return 0; } @@ -574,18 +566,16 @@ wal_commit_checkpoint_f(struct cbus_call_msg *data) } void -wal_commit_checkpoint(const struct vclock *vclock) +wal_commit_checkpoint(struct wal_checkpoint *checkpoint) { struct wal_writer *writer = &wal_writer_singleton; if (writer->wal_mode == WAL_NONE) { - vclock_copy(&writer->checkpoint_vclock, vclock); + vclock_copy(&writer->checkpoint_vclock, &checkpoint->vclock); return; } - struct wal_checkpoint msg; - vclock_copy(&msg.vclock, vclock); bool cancellable = fiber_set_cancellable(false); cbus_call(&wal_thread.wal_pipe, &wal_thread.tx_prio_pipe, - &msg.base, wal_commit_checkpoint_f, NULL, + &checkpoint->base, wal_commit_checkpoint_f, NULL, TIMEOUT_INFINITY); fiber_set_cancellable(cancellable); } diff --git a/src/box/wal.h b/src/box/wal.h index 3d6163535986c29926d2c1afb9b5a21516aa47c0..2564f7180a53157cc346477268f0dbc7415f0099 100644 --- a/src/box/wal.h +++ b/src/box/wal.h @@ -160,16 +160,26 @@ wal_mode(); void wal_sync(void); +struct wal_checkpoint { + struct cbus_call_msg base; + /** + * VClock of the last record written to the rotated WAL. + * This is the vclock that is supposed to be used to + * identify the new checkpoint. + */ + struct vclock vclock; +}; + /** * Prepare WAL for checkpointing. * * This function flushes all pending changes and rotates the - * current WAL. The vclock of the last record written to the - * rotated WAL is returned in @vclock. This is the vclock that - * is supposed to be used to identify the new checkpoint. + * current WAL. Checkpoint info is returned in @checkpoint. + * It is supposed to be passed to wal_commit_checkpoint() + * upon successful checkpoint creation. */ int -wal_begin_checkpoint(struct vclock *vclock); +wal_begin_checkpoint(struct wal_checkpoint *checkpoint); /** * This function is called upon successful checkpoint creation. @@ -177,7 +187,7 @@ wal_begin_checkpoint(struct vclock *vclock); * vclock. */ void -wal_commit_checkpoint(const struct vclock *vclock); +wal_commit_checkpoint(struct wal_checkpoint *checkpoint); /** * Remove WAL files that are not needed by consumers reading