[PATCH 07/13] gc: rename checkpoint_count to min_checkpoint_count
Vladimir Davydov
vdavydov.dev at gmail.com
Thu Oct 4 20:20:09 MSK 2018
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
More information about the Tarantool-patches
mailing list