From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp18.mail.ru (smtp18.mail.ru [94.100.176.155]) (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 B30B7469710 for ; Sun, 3 May 2020 21:44:24 +0300 (MSK) References: <20200428161137.20536-1-gorcunov@gmail.com> <20200428161137.20536-6-gorcunov@gmail.com> From: Vladislav Shpilevoy Message-ID: <1ee180ea-ad12-5d1f-e1b5-ccdae897ef08@tarantool.org> Date: Sun, 3 May 2020 20:44:22 +0200 MIME-Version: 1.0 In-Reply-To: <20200428161137.20536-6-gorcunov@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH 05/17] recovery: recover_xlog -- 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 3 comments below. > diff --git a/src/box/recovery.cc b/src/box/recovery.cc > index 55d89903f..f724600ed 100644 > --- a/src/box/recovery.cc > +++ b/src/box/recovery.cc > @@ -243,25 +243,28 @@ recovery_delete(struct recovery *r) > * The reading will be stopped on reaching stop_vclock. > * Use NULL for boundless recover > */ > -static void > +static int > recover_xlog(struct recovery *r, struct xstream *stream, > const struct vclock *stop_vclock) > { > + bool force_recovery = r->wal_dir.force_recovery; > struct xrow_header row; > uint64_t row_count = 0; > - while (xlog_cursor_next_xc(&r->cursor, &row, > - r->wal_dir.force_recovery) == 0) { 1. This function becomes unused and can be deleted now. > + int rc; > + > + while ((rc = xlog_cursor_next(&r->cursor, &row, force_recovery)) == 0) { > @@ -272,6 +275,7 @@ recover_xlog(struct recovery *r, struct xstream *stream, > * are signed with a zero replica id. > */ > assert(row.replica_id != 0 || row.group_id == GROUP_LOCAL); > + 2. Lets better omit unnecessary diff, even if it sometimes looks like it makes some parts of the code better. At least when it increases number of diff hunks. > /* > * We can promote the vclock either before or > * after xstream_write(): it only makes any impact > @@ -281,18 +285,24 @@ recover_xlog(struct recovery *r, struct xstream *stream, > vclock_follow_xrow(&r->vclock, &row); > if (xstream_write(stream, &row) == 0) { > ++row_count; > - if (row_count % 100000 == 0) > + if (row_count % 100000 == 0) { > say_info("%.1fM rows processed", > row_count / 1000000.); > - } else { > - if (!r->wal_dir.force_recovery) > - diag_raise(); > + } > + continue; > + } > > - say_error("skipping row {%u: %lld}", > - (unsigned)row.replica_id, (long long)row.lsn); > - diag_log(); > + if (!force_recovery) { > + rc = -1; > + break; > } > + > + say_error("skipping row {%u: %lld}", > + (unsigned)row.replica_id, (long long)row.lsn); > + diag_log(); > } > + > + return rc; 3. Probably better return 0/-1 just like all the other functions, which can either fail or succeed. Otherwise some new code in future for sure will check result using '!= 0', and that will be a bug. Because you can return 1 now.