[Tarantool-patches] [PATCH 06/17] recovery: recover_remaining_wals -- don't throw exception

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun May 3 21:44:51 MSK 2020


Thanks for the patch!

See 2 comments below.

> diff --git a/src/box/recovery.cc b/src/box/recovery.cc
> index f724600ed..1b78fc915 100644
> --- a/src/box/recovery.cc
> +++ b/src/box/recovery.cc
> @@ -316,14 +316,16 @@ recover_xlog(struct recovery *r, struct xstream *stream,
>   * This function will not close r->current_wal if
>   * recovery was successful.
>   */
> -void
> +int
>  recover_remaining_wals(struct recovery *r, struct xstream *stream,
>  		       const struct vclock *stop_vclock, bool scan_dir)
>  {
>  	struct vclock *clock;
>  
> -	if (scan_dir)
> -		xdir_scan_xc(&r->wal_dir);
> +	if (scan_dir) {
> +		if (xdir_scan(&r->wal_dir) == -1)
> +			return -1;
> +	}

1. Nit: you could make it twice shorter:

	if (scan_dir && xdir_scan(&r->wal_dir) != 0)
		return -1;

> diff --git a/src/box/relay.cc b/src/box/relay.cc
> index 2ad02cb8a..2e17d0476 100644
> --- a/src/box/relay.cc
> +++ b/src/box/relay.cc
> @@ -499,8 +501,11 @@ relay_process_wal_event(struct wal_watcher *watcher, unsigned events)
>  		return;
>  	}
>  	try {
> -		recover_remaining_wals(relay->r, &relay->stream, NULL,
> -				       (events & WAL_EVENT_ROTATE) != 0);
> +		bool scan_dir = (events & WAL_EVENT_ROTATE) ? true : false;

2. '!= 0' looked really simpler, and also had boolean type. Besides '!= 0' would
be consistent with other places. For example, when a function result is checked,
we write

	if (func() != 0)
		return -1;

instead of

	if (func() ? true : false)
		return -1;

For flags we also use direct boolean expression assignment. An example in the
same file: recovery.cc, variable scan_dir in hot_standby_f().


More information about the Tarantool-patches mailing list