Repository navigation
Conversation
…r wheel snapshot flush In snapshot mode the flush held lockWhenFlush across the whole timerlog flush + full-wheel backup + checkpoint, blocking enqueue for the entire I/O duration; the lock also sat at the call site, so subclass enqueue overrides bypassed it. - Move the lock inside putMessageToTimerWheel so every enqueue entry is serialized against the snapshot copy. - In flush(), only copy the wheel under the lock and capture wrotePosition as the snapshot flag; flush the timerlog to cover the copy's end, then write the snapshot and flush the checkpoint outside the lock. - Write the snapshot in 1 MiB segments (force per segment) to bound the writeback burst. - Keep the checkpoint at the pre-flush position so rollback replay stays covered.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #11522 +/- ##
=============================================
+ Coverage 49.79% 49.86% +0.07%
- Complexity 14407 14429 +22
=============================================
Files 1391 1391
Lines 103381 103414 +33
Branches 13529 13535 +6
=============================================
+ Hits 51477 51567 +90
+ Misses 45686 45625 -61
- Partials 6218 6222 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #11521.
In timer wheel snapshot mode (
timerWheelSnapshotFlush=true),TimerFlushService.flush()heldlockWhenFlushacross the entire timerlog flush + full-wheelbackup()(~36.9 MiB write + force) + checkpoint flush. Since the enqueue path takes the same lock per request, enqueue was blocked for the whole I/O duration, and the single large writeback burst inflated shared-disk CommitLog fsync tail latency. The lock also sat at the call site infetchAndPutTimerRequest()rather than insideputMessageToTimerWheel(), so a subclass overriding the enqueue loop bypassed it.This PR:
synchronized (lockWhenFlush)guard insideputMessageToTimerWheel()so every enqueue entry (including subclass overrides) is serialized against the snapshot copy.flush()to copy-first: freeze the wheel into a reusable buffer under the lock (fast memcpy) and capturewrotePositionas the snapshot flag, then flush the timerlog until it is durable up to the copy's end, write the snapshot, and flush the checkpoint — all outside the lock. A stall guard skips the snapshot if the timerlog flush cannot advance.force(false)per segment, finalforce(true)) instead of one full-wheel write + force, bounding the writeback burst.lastTimerLogFlushPosat the pre-flush position so it never runs ahead of the latest snapshot flag, preserving rollback-to-non-snapshot replay coverage.The on-disk format is unchanged. The snapshot flag is now the
wrotePositionat copy time (previously the post-flushflushedWhere); both are valid 52-byte record boundaries, so recovery via timerlog replay from the max snapshot flag is unchanged and old/new snapshots remain mutually readable. The non-snapshot (default) path is untouched.Test plan
TimerWheelTest,TimerMessageStoreTest,TimerCheckPointTest,TimerLogTest,TimerMetricsTest,TimerEngineSwitchVerifyTest).TimerWheelTestcases: snapshot copy isolation (live writes after the copy do not leak into the snapshot) and a multi-MiB segmented backup round-trip (per-slot equality across segments).TimerMessageStoreTestcases: snapshot flush + recovery with concurrent enqueue and long-delay messages (snapshot covers all records, checkpoint stays at/below the flag, offsets/read-time restored after restart, long-delay slots intact); snapshot-mode roll message delivery.