[Tarantool-patches] [PATCH 04/17] recovery: recovery_open_log -- don't throw exception
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sun May 3 21:43:47 MSK 2020
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;
> }
>
More information about the Tarantool-patches
mailing list