Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Sergey Petrenko <sergepetrenko@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [PATCH v2] replication: remove old snapshot files not needed by replicas
Date: Thu, 28 Jun 2018 18:18:18 +0300	[thread overview]
Message-ID: <20180628151818.6qx6y6xqdm5qrvk4@esperanza> (raw)
In-Reply-To: <1530197112.124405131@f490.i.mail.ru>

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 */

      reply	other threads:[~2018-06-28 15:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-28 12:09 Serge Petrenko
2018-06-28 13:00 ` Vladimir Davydov
2018-06-28 14:45   ` Re[2]: " Sergey Petrenko
2018-06-28 15:18     ` Vladimir Davydov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180628151818.6qx6y6xqdm5qrvk4@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH v2] replication: remove old snapshot files not needed by replicas' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox