[PATCH 2/2] vinyl: fix backup skipping vylog created after recovery

Vladimir Davydov vdavydov.dev at gmail.com
Sun Aug 19 23:44:40 MSK 2018


Commit 8e710090fcbc ("vinyl: simplify vylog recovery from backup") broke
backup in case the vylog directory is empty at the time of recovery
(i.e. vinyl isn't in use): before the commit we added the last
checkpoint vclock to the vylog directory index in this case while now we
don't. As a result, if the user starts using vinyl (creates a vinyl
space) after recovery, backup will not return the newly created vylog,
because it hasn't been indexed.

Fix this issue by restoring the code that adds the last checkpoint
vclock to the vylog directory index in case no vylog exists on recovery.

Closes #3624
---
https://github.com/tarantool/tarantool/issues/3624
https://github.com/tarantool/tarantool/commits/dv/gh-3624-vy-fix-vylog-backup

 src/box/vy_log.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/box/vy_log.c b/src/box/vy_log.c
index d8613170..fc8ede59 100644
--- a/src/box/vy_log.c
+++ b/src/box/vy_log.c
@@ -912,8 +912,17 @@ vy_log_begin_recovery(const struct vclock *vclock)
 	if (xdir_scan(&vy_log.dir) < 0 && errno != ENOENT)
 		return NULL;
 
-	if (xdir_last_vclock(&vy_log.dir, &vy_log.last_checkpoint) < 0)
+	if (xdir_last_vclock(&vy_log.dir, &vy_log.last_checkpoint) < 0) {
+		/*
+		 * Even if there's no vylog (i.e. vinyl isn't in use),
+		 * we still have to add the vclock to the xdir index,
+		 * because we may need it for garbage collection or
+		 * backup in case the user starts using vinyl after
+		 * recovery.
+		 */
+		xdir_add_vclock(&vy_log.dir, vclock);
 		vclock_copy(&vy_log.last_checkpoint, vclock);
+	}
 
 	int cmp = vclock_compare(&vy_log.last_checkpoint, vclock);
 	if (cmp > 0) {
-- 
2.11.0




More information about the Tarantool-patches mailing list