Skip to content

[backport 3.3] gc: use *.snap st_mtime to schedule after restart#11304

Merged
sergepetrenko merged 1 commit intorelease/3.3from
backport/release/3.3/11074
Mar 27, 2025
Merged

[backport 3.3] gc: use *.snap st_mtime to schedule after restart#11304
sergepetrenko merged 1 commit intorelease/3.3from
backport/release/3.3/11074

Conversation

@TarantoolBot
Copy link
Collaborator

@TarantoolBot TarantoolBot commented Mar 27, 2025

(This PR is a backport of #11074 to release/3.3 to a future 3.3.2 release.)


Introduce the timestamp field in gc_checkpoint so now gc.{c,h} are aware of actual times of checkpoints, which is important since this subsystem is responsible for scheduling. Now, one can track the unix time of a new checkpoint with new timestamp argument of gc_add_checkpoint. This change allows us to track previous checkpoints made before the server restart and even checkpoint_interval value reconfiguring.

This approach was chosen instead of just scanning the snap_dir in gc.c because it was engine-independent. One may also notice that even if the actual time after the last snapshot before the restart is greater than 2 * checkpoint_interval we won't start checkpointing immediately because that may cause high disk load in case of multiple instances. So in this case we just schedule a checkpoint at a random moment in the first checkpoint_interval seconds after the restart. It seems like even with this scheduling strategy a snapshot will be eventually created even during constant restarting.

Fixes #9820
NO_DOC=bugfix

Introduce the `timestamp` field in `gc_checkpoint` so now `gc.{c,h}` are
aware of actual times of checkpoints, which is important since this
subsystem is responsible for scheduling. Now, one can track the unix time
of a new checkpoint with new `timestamp` argument of `gc_add_checkpoint`.
This change allows us to track previous checkpoints made before the
server restart and even `checkpoint_interval` value reconfiguring.

This approach was chosen instead of just scanning the `snap_dir` in
`gc.c` because it was engine-independent. One may also notice that even
if the actual time after the last snapshot before the restart is greater
than `2 * checkpoint_interval` we won't start checkpointing immediately
because that may cause high disk load in case of multiple instances. So
in this case we just schedule a checkpoint at a random moment in the
first `checkpoint_interval` seconds after the restart. It seems like
even with this scheduling strategy a snapshot will be eventually created
even during constant restarting.

Fixes #9820
NO_DOC=bugfix

(cherry picked from commit d590c72)
@TarantoolBot TarantoolBot requested a review from a team as a code owner March 27, 2025 07:32
@TarantoolBot TarantoolBot changed the title [Backport release/3.3] gc: use *.snap st_mtime to schedule after restart [backport 3.3] gc: use *.snap st_mtime to schedule after restart Mar 27, 2025
@coveralls
Copy link

Coverage Status

coverage: 87.454% (-0.01%) from 87.468%
when pulling d4fffef on backport/release/3.3/11074
into 2a255ef
on release/3.3
.

@sergepetrenko sergepetrenko merged commit 7ff9045 into release/3.3 Mar 27, 2025
25 checks passed
@sergepetrenko sergepetrenko deleted the backport/release/3.3/11074 branch March 27, 2025 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants