Skip to content

Perform WAL checkpointing ten times per second#89

Merged
OpsBotPrime merged 2 commits intomasterfrom
even-more-often-wal-checkpointing
Apr 1, 2026
Merged

Perform WAL checkpointing ten times per second#89
OpsBotPrime merged 2 commits intomasterfrom
even-more-often-wal-checkpointing

Conversation

@Qqwy
Copy link
Copy Markdown
Contributor

@Qqwy Qqwy commented Apr 1, 2026

Before: once per second
With this PR: ten times per second.

Copy link
Copy Markdown
Contributor

@ReinierMaas ReinierMaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Let's get the WAL size under control.

@Qqwy
Copy link
Copy Markdown
Contributor Author

Qqwy commented Apr 1, 2026

@OpsBotPrime merge and tag

Approved-by: Qqwy
Priority: Normal
Auto-deploy: false
@OpsBotPrime
Copy link
Copy Markdown
Contributor

Rebased as 3104526, waiting for CI …

@OpsBotPrime
Copy link
Copy Markdown
Contributor

CI job 🟡 started.

pub async fn periodically_checkpoint_wal(&self) {
const EXPLICIT_WAL_CHECK_INTERVAL: Duration = Duration::from_secs(1);
const EXPLICIT_WAL_CHECK_INTERVAL: Duration = Duration::from_millis(100);
let mut interval = tokio::time::interval(EXPLICIT_WAL_CHECK_INTERVAL);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to set the missed tick strategy, otherwise this will repeatedly issue checkpoints whenever the checkpoints takes too long. This will be exacerbated by the interval being shortened.

Suggested change
let mut interval = tokio::time::interval(EXPLICIT_WAL_CHECK_INTERVAL);
let mut interval = tokio::time::interval(EXPLICIT_WAL_CHECK_INTERVAL);
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);

The default behaviour is "burst", i.e. fire all missed ticks right now. This is not what we want here. We don't actually rely on the number of checkpoints, we just want to fire them regularly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing a checkpoint when there is (almost) nothing to checkpoint is (almost) free, though it will of course add to the congestion on the one writer DB connection.

Changing to Skip is a nice next step. I'll also add explicit checkpoints to the two write-heavy points of the app, in a follow-up PR.

@OpsBotPrime
Copy link
Copy Markdown
Contributor

@Qqwy I tagged your PR with v48. Please wait for the build of 3104526 to pass and don't forget to deploy it!

@OpsBotPrime OpsBotPrime merged commit 3104526 into master Apr 1, 2026
5 of 7 checks passed
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