From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) (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 804AF4696C3 for ; Tue, 28 Apr 2020 19:12:48 +0300 (MSK) Received: by mail-lf1-f68.google.com with SMTP id k28so17374709lfe.10 for ; Tue, 28 Apr 2020 09:12:48 -0700 (PDT) From: Cyrill Gorcunov Date: Tue, 28 Apr 2020 19:11:24 +0300 Message-Id: <20200428161137.20536-5-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 04/17] recovery: recovery_open_log -- 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/recovery.cc | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/box/recovery.cc b/src/box/recovery.cc index 16e38cee2..55d89903f 100644 --- a/src/box/recovery.cc +++ b/src/box/recovery.cc @@ -162,17 +162,18 @@ recovery_close_log(struct recovery *r) return 0; } -static void +static int recovery_open_log(struct recovery *r, const struct vclock *vclock) { - XlogGapError *e; struct xlog_meta meta = r->cursor.meta; enum xlog_cursor_state state = r->cursor.state; + int rc = 0; if (recovery_close_log(r) != 0) - diag_raise(); + return -1; - xdir_open_cursor_xc(&r->wal_dir, vclock_sum(vclock), &r->cursor); + if (xdir_open_cursor(&r->wal_dir, vclock_sum(vclock), &r->cursor) != 0) + return -1; if (state == XLOG_CURSOR_NEW && vclock_compare(vclock, &r->vclock) > 0) { @@ -205,15 +206,16 @@ recovery_open_log(struct recovery *r, const struct vclock *vclock) */ if (vclock_compare(&r->vclock, vclock) < 0) vclock_copy(&r->vclock, vclock); - return; + return rc; gap_error: - e = tnt_error(XlogGapError, &r->vclock, vclock); - if (!r->wal_dir.force_recovery) - throw e; - /* Ignore missing WALs if force_recovery is set. */ - e->log(); - say_warn("ignoring a gap in LSN"); + diag_set(XlogGapError, &r->vclock, vclock); + if (r->wal_dir.force_recovery) { + diag_log(); + say_warn("ignoring a gap in LSN"); + } else { + rc = -1; + } goto out; } @@ -345,7 +347,8 @@ recover_remaining_wals(struct recovery *r, struct xstream *stream, continue; } - recovery_open_log(r, clock); + if (recovery_open_log(r, clock) != 0) + diag_raise(); say_info("recover from `%s'", r->cursor.name); -- 2.20.1