Repository navigation
fix(#11989): the Raft log compaction forces the data files on its own thread before the checkpoint - #11995
Conversation
…s own thread before the checkpoint - Since ArcadeData#11519 the checkpoint forces every open database's data files, on the Ratis StateMachineUpdater, which is the apply thread: every commit of the node waited for it, up to 1.6 s in an application's ingest. - RaftLogCompactionTarget.triggerSnapshot() runs the same pass first, on the scheduler's thread; the checkpoint's own pass is unchanged and now only forces what was written in between. The early pass logs a failure at FINE. - Issue11989CheckpointSyncsOffTheApplyThreadIT reads what the apply thread still had to force through a test hook.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 3 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
This pull request is merged. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Validated in a real workload. The patched image is 26.12.1-SNAPSHOT (main The |
|
Triage: The change is small and targeted, and it looks correct. I read the diff only and did not run it. What it does: Why it is safe:
Test: Minor notes (non-blocking):
The linked issue is 1 value(s) redacted. |
…y when Ratis will checkpoint Builds on the early pass of the previous commit, which moves the checkpoint's data-file forcing from the apply thread to the log compaction thread. - The early pass ran on every tick, also when Ratis answers the request without a checkpoint because fewer than creationGap entries were applied since the latest snapshot. A node with a few writes below the gap paid a data-file fsync pass per snapshotInterval for a tick that purges nothing. It now applies the same test as RaftServerImpl.takeSnapshotAsync, on the same two indexes, and forces nothing below the gap. - Nothing thrown by the early pass (a database closed or swapped under it) may keep the tick from asking for the checkpoint: it is caught and logged at FINE, the checkpoint forces what is open by then. - The regression test moves into RaftLogCompactionWiringIT (same fixture, tagged slow) since main no longer keeps Issue*-named classes in ha-raft, with a second test for the gap. The Javadoc drops a figure measured on one workload. The entry-count auto-trigger and the pre-install purge still force on the apply thread: ArcadeData#12587.
|
Triage: The approach is sound: forcing the data files on the scheduler thread before the apply-thread checkpoint, and skipping it below the creation gap. I found one problem that blocks the merge, plus two smaller ones. Blocker: the test will not compile.
Description does not match the diff.
Minor points.
1 value(s) redacted. |
…g creation-gap answer costs
|
On the review of 5cf9634: |
|
Triage: The change is small and focused. The compaction target now forces the data files on the scheduler thread before it asks Ratis for the snapshot.
Optional, minor: the Javadoc and the PR body point to "#12587" for the remaining apply-thread forcing paths. Check that this is the issue number you mean. I could not run the build or the tests here, so I am relying on the author's reported results. |
Fixes #11989.
Problem
Since #11519 (issue #11258),
ArcadeStateMachine.takeSnapshot()forces the data files of every open database before it writes the snapshot marker. Ratis runstakeSnapshot()on itsStateMachineUpdaterthread, which is the apply thread, so every commit of the node waits while the files written since the previous checkpoint are forced. The periodic log compaction triggers one checkpoint persnapshotInterval. On an application's 3-node ingest, the leader's JFR showed the compaction waiting 0.24-1.63 s for the checkpoint once per 20-minute run. During the longest one, the group committer and 12commitTransactioncalls were parked for up to 1.57 s.Change
RaftLogCompactionTarget.triggerSnapshot()callsArcadeStateMachine.syncDataFilesAheadOfCheckpoint(creationGap)on the scheduler's thread before it asks Ratis for the snapshot. That is the samesyncDataFilesOfOpenDatabases()pass: it waits for the pages pending in the asynchronous flush and then forces the files written since their last fsync.takeSnapshot()still runs its own pass, so the guarantee of the marker does not depend on the new call.PaginatedComponentFile.forceIfModified()skips the files that are clean by then, so the apply thread only forces what was written between the two passes.creationGapentries applied since the latest snapshot, the test ofRaftServerImpl.takeSnapshotAsync), so a tick below the gap pays no fsync.RaftLogCompactionSchedulerJavadoc said a snapshot is "cheap enough"; it now names what the snapshot costs and where that cost is paid.The pre-install purge (
compactRaftLogBeforeSnapshotInstall) is unchanged. It runs only under disk pressure, with a short timeout on purpose. It and the entry-count auto-trigger still force on the apply thread: #12587.Test
RaftLogCompactionWiringIT(ha-raft, 3 nodes),theCompactionForcesTheDataFilesBeforeTheApplyThreadCheckpoints:TEST_BEFORE_CHECKPOINT_SYNChook (Consumer<ArcadeStateMachine>, filtered to the leader's state machine) records which data files the apply thread still has to force when the checkpoint reaches its sync.triggerSnapshot(1).aTickBelowTheCreationGapForcesNoDataFilecallstriggerSnapshot(Long.MAX_VALUE): Ratis takes no checkpoint and the data files still owe their fsync. It fails with the gap test removed.Results:
triggerSnapshot()removed, it fails: the apply thread still haddictionary.0.65536.v1.dict,Account_0.28.65536.v0.bucketandAccount_1.29.65536.v0.bucketto force.AppliedIndexCheckpointTest(36 tests, the HA power loss (#11250 residue): lost file/header pages after fsync, torn pages without WAL history, unavailable unique index #11258 tests among them),RaftLogCompactionSchedulerTest(17 tests) andRaftPeriodicSnapshotCompactionIT(2 tests) pass.