Repository navigation
rocketmq: avoid scanning clean TimerWheel pages during flush - #11509
Open
user-Param wants to merge 4 commits into
Open
user-Param wants to merge 4 commits into
user-Param wants to merge 4 commits into
Conversation
added 3 commits
November 12, 2026 11:23
Add per-page dirty tracking to TimerWheel.flush(). Instead of scanning every byte in the wheel on each flush, track which logical 4 KiB pages were modified via putSlot/reviseSlot and only scan dirty pages. Use a claim/clear CAS pattern on an AtomicIntegerArray of page flags: - Writers mark pages dirty (PAGE_DIRTY) in finally blocks - Flush claims dirty pages (PAGE_DIRTY -> PAGE_CLAIMED), scans only those, then clears to clean (PAGE_CLAIMED -> PAGE_CLEAN) - If a writer marks dirty during processing, CAS fails and page stays dirty - If copy throws, page is restored to dirty for retry Retains MappedByteBuffer.force() even when all flags are clean. Preserves slot/file layout and snapshot backup path. Fixes apache#11508 Signed-off-by: melon tusk <paramjeetsingh.dev.mail@gmail.com>
IOTinyUtils.copyFile() opens the destination with FileOutputStream before reading the source. If source and target refer to the same file (or hard link), the destination open truncates the source first, resulting in an empty file. Check Files.isSameFile() before opening the destination and reject the operation with IllegalArgumentException. Fixes apache#11500 Signed-off-by: melon tusk <paramjeetsingh.dev.mail@gmail.com>
TimerMessageStore.checkAndReviseMetrics() passes Long.MAX_VALUE (the sentinel from TimerWheel.checkPhyPos() when no eligible slot exists) directly to timerLog.getWholeBuffer(), causing an out-of-range warning log. Guard against the sentinel before calling getWholeBuffer and break the scan loop cleanly. Fixes apache#11498 Signed-off-by: melon tusk <paramjeetsingh.dev.mail@gmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #11509 +/- ##
=============================================
- Coverage 49.79% 49.79% -0.01%
+ Complexity 14407 14406 -1
=============================================
Files 1391 1391
Lines 103381 103404 +23
Branches 13529 13535 +6
=============================================
+ Hits 51477 51485 +8
- Misses 45686 45698 +12
- Partials 6218 6221 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add test for IOTinyUtils.copyFile to verify that copying a file to itself throws IllegalArgumentException. This covers the new check added in GSoC PR apache#11509 that prevents copying a file to itself. Fixes apache#11509 Signed-off-by: Paramjeet Singh <user-Param@users.noreply.github.com>
Author
|
@RongtongJin @shijianxk Could you please review this PR when you have a chance? Thank you! |
Author
|
@shijia.wxr Could you please review this PR when you have a chance? Thank you! |
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.
Fixes #11508
Add per-page dirty tracking to TimerWheel.flush(). Instead of scanning
every byte in the wheel on each flush, track which logical 4 KiB pages
were modified via putSlot/reviseSlot and only scan dirty pages.
Use a claim/clear CAS pattern on an AtomicIntegerArray of page flags:
then clears to clean (PAGE_CLAIMED -> PAGE_CLEAN)
Retains MappedByteBuffer.force() even when all flags are clean.
Preserves slot/file layout and snapshot backup path.
Signed-off-by: user-Param user-Param@users.noreply.github.com