From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp33.i.mail.ru (smtp33.i.mail.ru [94.100.177.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C1604469710 for ; Sun, 3 May 2020 21:43:48 +0300 (MSK) References: <20200428161137.20536-1-gorcunov@gmail.com> <20200428161137.20536-5-gorcunov@gmail.com> From: Vladislav Shpilevoy Message-ID: Date: Sun, 3 May 2020 20:43:47 +0200 MIME-Version: 1.0 In-Reply-To: <20200428161137.20536-5-gorcunov@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [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: Cyrill Gorcunov , tml Thanks for the patch! See 2 comments below. > 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); 1. The function becomes unused and can be deleted now. > + 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; 2. By going out here you execute 'vclock_copy(&r->vclock, vclock);' code line. Which wasn't executed previously, when exception was thrown above, in 'throw e;' code line. So I guess you can just do 'return -1;' here, turn 'return rc;' into 'return 0;' above, and remove 'int rc;' at all. If I am not missing something. > + } > goto out; > } >