From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH v2 2/8] vinyl: update recovery context with records written during recovery Date: Sun, 27 May 2018 22:05:50 +0300 Message-Id: <958a42889026e5ed70ac64d732b51d3ff9accca2.1527446023.git.vdavydov.dev@gmail.com> In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: During recovery, we may write VY_LOG_CREATE_LSM and VY_LOG_DROP_LSM records we failed to write before restart (because those records are written after WAL and hence may not make it to vylog). Right after recovery we invoke garbage collection to drop incomplete runs. Once VY_LOG_PREPARE_LSM record is introduced, we will also collect incomplete LSM trees there (those we failed to build). However, there may be LSM trees we managed to build but failed to write VY_LOG_CREATE_LSM for. This is OK as we will retry vylog write, but currenntly it isn't reflected in the recovery context used for garbage collection. To avoid purging such LSM trees, let's update the recovery context with records written during recovery. Needed for #1653 --- src/box/vy_log.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/box/vy_log.c b/src/box/vy_log.c index bdf9eee3..069cd528 100644 --- a/src/box/vy_log.c +++ b/src/box/vy_log.c @@ -177,6 +177,10 @@ static struct vy_log vy_log; static struct vy_recovery * vy_recovery_new_locked(int64_t signature, bool only_checkpoint); +static int +vy_recovery_process_record(struct vy_recovery *recovery, + const struct vy_log_record *record); + /** * Return the name of the vylog file that has the given signature. */ @@ -890,6 +894,14 @@ vy_log_end_recovery(void) { assert(vy_log.recovery != NULL); + /* + * Update the recovery context with records written during + * recovery - we will need them for garbage collection. + */ + struct vy_log_record *record; + stailq_foreach_entry(record, &vy_log.tx, in_tx) + vy_recovery_process_record(vy_log.recovery, record); + /* Flush all pending records. */ if (vy_log_flush() < 0) { diag_log(); -- 2.11.0