Skip to content
Snippets Groups Projects
Commit 1162743a authored by Vladimir Davydov's avatar Vladimir Davydov
Browse files

gc: rename checkpoint_count to min_checkpoint_count

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 5512053f ("box: gc: do not remove files
being backed up").
parent 1ed5f1e9
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -116,8 +116,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);
......@@ -127,8 +127,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);
......@@ -138,7 +139,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))
......@@ -188,9 +189,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 *
......
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment