[PATCH v2] replication: remove old snapshot files not needed by replicas

Vladimir Davydov vdavydov.dev at gmail.com
Thu Jun 28 18:18:18 MSK 2018


On Thu, Jun 28, 2018 at 05:45:12PM +0300, Sergey Petrenko wrote:
> >> @@ -234,6 +218,7 @@ gc_run(void)
> >>  	 * executions.
> >>  	 */
> >>  	latch_lock(&gc.latch);
> >> +
> >>  	/*
> >>  	 * Run garbage collection.
> >>  	 *
> >
> >Please try to avoid stray hunks, like this one, when preparing a patch.
> >They complicate review. 
> Wym?

I mean, before submitting your patch, please self review it and make
sure, there's no changes that are irrelevant (or not necessary) and that
add new @@ sections to the patch. Please don't add/remove extra lines or
fix comments or fix coding-style if this adds new hunks (@@) to your
patch.

> >
> >> @@ -241,8 +226,17 @@ gc_run(void)
> >>  	 * collection for memtx snapshots first and abort if it
> >>  	 * fails - see comment to memtx_engine_collect_garbage().
> >>  	 */
> >> -	if (engine_collect_garbage(gc_snap_signature) == 0)
> >> -		wal_collect_garbage(gc_xlog_signature);
> >> +	int rc = 0;
> >> +
> >> +	if (gc_checkpoint_signature > gc.checkpoint_signature) {
> >> +		gc.checkpoint_signature = gc_checkpoint_signature;
> >> +		rc = engine_collect_garbage(gc_checkpoint_signature);
> >> +	}
> >> +	if (gc_wal_signature > gc.wal_signature) {
> >> +		gc.wal_signature = gc_wal_signature;
> >> +		if (rc == 0)
> >> +			wal_collect_garbage(gc_wal_signature);
> >> +	}
> >
> >I guess, in case engine_collect_garbage() fails and we don't call
> >wal_collect_garbage(), we shouldn't advance gc.wal_signature:
> >
> >if (rc == 0 && gc_wal_signature > gc.wal_signature) {
> >gc.wal_signature = gc_wal_signature;
> >wal_collect_garbage(gc_wal_signature);
> >}
> That's how it was done previously. First update gc.signature, and only then
> try to run encgine_collect_garbage() and wal_collect_garbage(), so I decided
> to leave it as is.

OK.

Your mail agent mangles indentation so that the patch you pasted
below is unreadable. Please install a patch-friendly mail agent,
e.g. Thunderbird.

Regarding indentation, I guess I didn't make myself quite clear: if
there's a parenthesis, try to keep the code aligned to it using both
tabs and spaces, otherwise use only tabs, e.g.

	if (long_condition_one &&
	    another_condition)
		do_something();

but

	struct long_type_name long_var_name =
		initializer_function();

Rule of thumb: look at the code around you and follow it closely.

Also, try to fit your code in 80 chars.

I fixed indentation by myself on the branch. The patch looks good to me
now. Please send v3 (no changes, just git-send-email + don't forget to
add changelog) so that I can ack it and Kostja can review it.

> 
> ---
> src/box/gc.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
> diff --git a/src/box/gc.c b/src/box/gc.c
> index 06d2fbd35..4d8f321ff 100644
> --- a/src/box/gc.c
> +++ b/src/box/gc.c
> @@ -161,7 +161,7 @@ gc_free(void)
> latch_destroy(&gc.latch);
> }
> 
> -/** Find the consumer that uses the oldest checkpoint */
> +/** Find the consumer that uses the oldest checkpoint. */
> struct gc_consumer *
> gc_tree_first_checkpoint(gc_tree_t *consumers)
> {
> @@ -181,7 +181,7 @@ gc_run(void)
> struct gc_consumer *leftmost = gc_tree_first(&gc.consumers);
> /* Look up the consumer that uses the oldest checkpoint. */
> struct gc_consumer *leftmost_checkpoint =
> - gc_tree_first_checkpoint(&gc.consumers);
> + gc_tree_first_checkpoint(&gc.consumers);
> 
> /*
> * Find the oldest checkpoint that must be preserved.
> @@ -198,17 +198,17 @@ gc_run(void)
> if (--checkpoint_count > 0)
> continue;
> if (leftmost_checkpoint != NULL &&
> - leftmost_checkpoint->signature < vclock_sum(vclock))
> + leftmost_checkpoint->signature < vclock_sum(vclock))
> continue;
> gc_checkpoint_signature = vclock_sum(vclock);
> break;
> }
> 
> int64_t gc_wal_signature = MIN(gc_checkpoint_signature, leftmost != NULL ?
> - leftmost->signature : INT64_MAX);
> + leftmost->signature : INT64_MAX);
> 
> if (gc_checkpoint_signature <= gc.checkpoint_signature &&
> - gc_wal_signature <= gc.wal_signature)
> + gc_wal_signature <= gc.wal_signature)
> return; /* nothing to do */



More information about the Tarantool-patches mailing list