From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 07/13] gc: rename checkpoint_count to min_checkpoint_count Date: Thu, 4 Oct 2018 20:20:09 +0300 [thread overview] Message-ID: <bd808f6896935c679dd79c07f7262b12fc81a1eb.1538671546.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1538671546.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1538671546.git.vdavydov.dev@gmail.com> Because it's the minimal number of checkpoints that must not be deleted, not the actual number of preserved checkpoints. Do it now, in a separate patch so as to ease review of the next patch. While we are at it, fix the comment to gc_set_(min_)checkpoint_count() which got outdated by commit 5512053fa281 ("box: gc: do not remove files being backed up"). --- src/box/box.cc | 2 +- src/box/gc.c | 15 ++++++++------- src/box/gc.h | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index bdf71eb2..49deea61 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -826,7 +826,7 @@ box_set_checkpoint_count(void) { int checkpoint_count = cfg_geti("checkpoint_count"); box_check_checkpoint_count(checkpoint_count); - gc_set_checkpoint_count(checkpoint_count); + gc_set_min_checkpoint_count(checkpoint_count); } void diff --git a/src/box/gc.c b/src/box/gc.c index 100c972f..dca278af 100644 --- a/src/box/gc.c +++ b/src/box/gc.c @@ -108,8 +108,8 @@ gc_tree_first_checkpoint(gc_tree_t *consumers) void gc_run(void) { - int checkpoint_count = gc.checkpoint_count; - assert(checkpoint_count > 0); + int min_checkpoint_count = gc.min_checkpoint_count; + assert(min_checkpoint_count > 0); /* Look up the consumer that uses the oldest WAL. */ struct gc_consumer *leftmost = gc_tree_first(&gc.consumers); @@ -119,8 +119,9 @@ gc_run(void) /* * Find the oldest checkpoint that must be preserved. - * We have to maintain @checkpoint_count oldest checkpoints, - * plus we can't remove checkpoints that are still in use. + * We have to preserve @min_checkpoint_count oldest + * checkpoints, plus we can't remove checkpoints that + * are still in use. */ struct vclock gc_checkpoint_vclock; vclock_create(&gc_checkpoint_vclock); @@ -130,7 +131,7 @@ gc_run(void) const struct vclock *vclock; while ((vclock = checkpoint_iterator_prev(&checkpoints)) != NULL) { - if (--checkpoint_count > 0) + if (--min_checkpoint_count > 0) continue; if (leftmost_checkpoint != NULL && vclock_sum(&leftmost_checkpoint->vclock) < vclock_sum(vclock)) @@ -180,9 +181,9 @@ gc_run(void) } void -gc_set_checkpoint_count(int checkpoint_count) +gc_set_min_checkpoint_count(int min_checkpoint_count) { - gc.checkpoint_count = checkpoint_count; + gc.min_checkpoint_count = min_checkpoint_count; } struct gc_consumer * diff --git a/src/box/gc.h b/src/box/gc.h index 6e2a4910..418f8d5e 100644 --- a/src/box/gc.h +++ b/src/box/gc.h @@ -75,8 +75,11 @@ typedef rb_tree(struct gc_consumer) gc_tree_t; /** Garbage collection state. */ struct gc_state { - /** Number of checkpoints to maintain. */ - int checkpoint_count; + /** + * Minimal number of checkpoints to preserve. + * Configured by box.cfg.checkpoint_count. + */ + int min_checkpoint_count; /** Max vclock WAL garbage collection has been called for. */ struct vclock wal_vclock; /** Max vclock checkpoint garbage collection has been called for. */ @@ -112,11 +115,15 @@ void gc_run(void); /** - * Update the checkpoint_count configuration option and - * rerun garbage collection. + * Update the minimal number of checkpoints to preserve. + * Called when box.cfg.checkpoint_count is updated. + * + * Note, this function doesn't run garbage collector so + * changes will take effect only after a new checkpoint + * is created or a consumer is unregistered. */ void -gc_set_checkpoint_count(int checkpoint_count); +gc_set_min_checkpoint_count(int min_checkpoint_count); /** * Register a consumer. -- 2.11.0
next prev parent reply other threads:[~2018-10-04 17:20 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-10-04 17:20 [PATCH 00/13] box: garbage collection refactoring and fixes Vladimir Davydov 2018-10-04 17:20 ` [PATCH 01/13] vinyl: fix master crash on replica join failure Vladimir Davydov 2018-10-04 21:43 ` Konstantin Osipov 2018-10-04 17:20 ` [PATCH 02/13] vinyl: force deletion of runs left from unfinished indexes on restart Vladimir Davydov 2018-10-04 21:44 ` Konstantin Osipov 2018-10-04 17:20 ` [PATCH 03/13] gc: make gc_consumer and gc_state structs transparent Vladimir Davydov 2018-10-04 21:47 ` Konstantin Osipov 2018-10-04 17:20 ` [PATCH 04/13] gc: use fixed length buffer for storing consumer name Vladimir Davydov 2018-10-04 21:47 ` Konstantin Osipov 2018-10-04 17:20 ` [PATCH 05/13] gc: fold gc_consumer_new and gc_consumer_delete Vladimir Davydov 2018-10-04 21:50 ` Konstantin Osipov 2018-10-05 8:56 ` Vladimir Davydov 2018-10-04 17:20 ` [PATCH 06/13] gc: format consumer name in gc_consumer_register Vladimir Davydov 2018-10-04 21:50 ` Konstantin Osipov 2018-10-04 17:20 ` Vladimir Davydov [this message] 2018-10-04 21:51 ` [PATCH 07/13] gc: rename checkpoint_count to min_checkpoint_count Konstantin Osipov 2018-10-04 17:20 ` [PATCH 08/13] gc: keep track of available checkpoints Vladimir Davydov 2018-10-04 21:59 ` Konstantin Osipov 2018-10-05 8:50 ` Vladimir Davydov 2018-10-04 17:20 ` [PATCH 09/13] gc: cleanup garbage collection procedure Vladimir Davydov 2018-10-04 22:00 ` Konstantin Osipov 2018-10-04 17:20 ` [PATCH 10/13] gc: improve box.info.gc output Vladimir Davydov 2018-10-04 22:01 ` Konstantin Osipov 2018-10-04 17:20 ` [PATCH 11/13] gc: separate checkpoint references from wal consumers Vladimir Davydov 2018-10-04 22:05 ` Konstantin Osipov 2018-10-04 17:20 ` [PATCH 12/13] gc: call gc_run unconditionally when consumer is advanced Vladimir Davydov 2018-10-04 22:26 ` Konstantin Osipov 2018-10-04 17:20 ` [PATCH 13/13] replication: ref checkpoint needed to join replica Vladimir Davydov 2018-10-04 22:27 ` Konstantin Osipov 2018-10-05 17:03 ` [PATCH 00/13] box: garbage collection refactoring and fixes Vladimir Davydov
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=bd808f6896935c679dd79c07f7262b12fc81a1eb.1538671546.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 07/13] gc: rename checkpoint_count to min_checkpoint_count' \ /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