From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4D8684696C3 for ; Tue, 28 Apr 2020 19:13:58 +0300 (MSK) Received: by mail-lf1-f67.google.com with SMTP id 198so17413137lfo.7 for ; Tue, 28 Apr 2020 09:13:58 -0700 (PDT) From: Cyrill Gorcunov Date: Tue, 28 Apr 2020 19:11:30 +0300 Message-Id: <20200428161137.20536-11-gorcunov@gmail.com> In-Reply-To: <20200428161137.20536-1-gorcunov@gmail.com> References: <20200428161137.20536-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 10/17] recovery: recovery_scan -- don't throw exception List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Prepare for transition to plain C. Signed-off-by: Cyrill Gorcunov --- 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