[Tarantool-patches] [PATCH 10/17] recovery: recovery_scan -- don't throw exception

Cyrill Gorcunov gorcunov at gmail.com
Tue Apr 28 19:11:30 MSK 2020


Prepare for transition to plain C.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 src/box/box.cc      |  3 ++-
 src/box/recovery.cc | 18 +++++++++++++-----
 src/box/recovery.h  |  2 +-
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/box/box.cc b/src/box/box.cc
index 4371c1986..c269a5da8 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -2243,7 +2243,8 @@ local_recovery(const struct tt_uuid *instance_uuid,
 	 * so we must reflect this in replicaset vclock to
 	 * not attempt to apply these rows twice.
 	 */
-	recovery_scan(recovery, &replicaset.vclock, &gc.vclock);
+	if (recovery_scan(recovery, &replicaset.vclock, &gc.vclock) != 0)
+		diag_raise();
 	say_info("instance vclock %s", vclock_to_string(&replicaset.vclock));
 
 	if (wal_dir_lock >= 0) {
diff --git a/src/box/recovery.cc b/src/box/recovery.cc
index 1c7665f87..af7910bdf 100644
--- a/src/box/recovery.cc
+++ b/src/box/recovery.cc
@@ -115,18 +115,19 @@ recovery_new(const char *wal_dirname, bool force_recovery,
 	return r;
 }
 
-void
+int
 recovery_scan(struct recovery *r, struct vclock *end_vclock,
 	      struct vclock *gc_vclock)
 {
-	xdir_scan_xc(&r->wal_dir);
+	if (xdir_scan(&r->wal_dir) == -1)
+		return -1;
 
 	if (xdir_last_vclock(&r->wal_dir, end_vclock) < 0 ||
 	    vclock_compare(end_vclock, &r->vclock) < 0) {
 		/* No xlogs after last checkpoint. */
 		vclock_copy(gc_vclock, &r->vclock);
 		vclock_copy(end_vclock, &r->vclock);
-		return;
+		return 0;
 	}
 
 	if (xdir_first_vclock(&r->wal_dir, gc_vclock) < 0)
@@ -134,12 +135,19 @@ recovery_scan(struct recovery *r, struct vclock *end_vclock,
 
 	/* Scan the last xlog to find end vclock. */
 	struct xlog_cursor cursor;
-	if (xdir_open_cursor(&r->wal_dir, vclock_sum(end_vclock), &cursor) != 0)
-		return;
+	if (xdir_open_cursor(&r->wal_dir, vclock_sum(end_vclock), &cursor) != 0) {
+		/*
+		 * FIXME: Why do we ignore errors?!
+		 */
+		return 0;
+	}
+
 	struct xrow_header row;
 	while (xlog_cursor_next(&cursor, &row, true) == 0)
 		vclock_follow_xrow(end_vclock, &row);
+
 	xlog_cursor_close(&cursor, false);
+	return 0;
 }
 
 static int
diff --git a/src/box/recovery.h b/src/box/recovery.h
index 7aa496b14..90fbf1b0a 100644
--- a/src/box/recovery.h
+++ b/src/box/recovery.h
@@ -74,7 +74,7 @@ recovery_delete(struct recovery *r);
  * @gc_vclock is set to the oldest vclock available in the
  * WAL directory.
  */
-void
+int
 recovery_scan(struct recovery *r,  struct vclock *end_vclock,
 	      struct vclock *gc_vclock);
 
-- 
2.20.1



More information about the Tarantool-patches mailing list