You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "guyinyou (via GitHub)" <gi...@apache.org> on 2025/09/25 10:59:41 UTC
[PR] [ISSUE #9735] Add TimerWheel snapshot mechanism for reliable recovery [rocketmq]
guyinyou opened a new pull request, #9736:
URL: https://github.com/apache/rocketmq/pull/9736
- Add snapshot backup and recovery functionality to TimerWheel
- Add configuration options for snapshot control with backward compatibility
- Implement atomic flush operations with synchronization locks
- Add snapshot file management (creation, cleanup, selection)
- Support recovery from snapshot files to avoid rebuilding TimerWheel
- Add TimerFlushService.flush() method for manual flush operations
This addresses the issue where discrete TimerWheel state cannot be recovered from TimerLog alone, ensuring data consistency and improving recovery performance.
Configuration changes:
- timerWheelSnapshotFlush: enable/disable snapshot functionality (default: false)
- timerWheelDefaultFlush: enable/disable default flush behavior (default: true)
- timerWheelSnapshotIntervalMs: snapshot creation interval (default: 10s)
Change-Id: I801ce7ca6330d02aefcae905e59e1e2b7642ebf5
<!-- Please make sure the target branch is right. In most case, the target branch should be `develop`. -->
### Which Issue(s) This PR Fixes
<!-- Please ensure that the related issue has already been created, and [link this pull request to that issue using keywords](<https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword>) to ensure automatic closure. -->
Fixes #9735
### Brief Description
<!-- Write a brief description for your pull request to help the maintainer understand the reasons behind your changes. -->
### How Did You Test This Change?
<!-- In order to ensure the code quality of Apache RocketMQ, we expect every pull request to have undergone thorough testing. -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE #9735] Add TimerWheel snapshot mechanism for reliable recovery [rocketmq]
Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin commented on code in PR #9736:
URL: https://github.com/apache/rocketmq/pull/9736#discussion_r2427982165
##########
store/src/main/java/org/apache/rocketmq/store/timer/TimerMessageStore.java:
##########
@@ -1805,33 +1828,48 @@ private String format(long time) {
@Override
public void run() {
TimerMessageStore.LOGGER.info(this.getServiceName() + " service start");
- long start = System.currentTimeMillis();
while (!this.isStopped()) {
try {
- prepareTimerCheckPoint();
- timerLog.getMappedFileQueue().flush(0);
- timerWheel.flush();
- timerCheckpoint.flush();
- if (System.currentTimeMillis() - start > storeConfig.getTimerProgressLogIntervalMs()) {
- start = System.currentTimeMillis();
- long tmpQueueOffset = currQueueOffset;
- ConsumeQueueInterface cq = messageStore.getConsumeQueue(TIMER_TOPIC, 0);
- long maxOffsetInQueue = cq == null ? 0 : cq.getMaxOffsetInQueue();
- TimerMessageStore.LOGGER.info("[{}]Timer progress-check commitRead:[{}] currRead:[{}] currWrite:[{}] readBehind:{} currReadOffset:{} offsetBehind:{} behindMaster:{} " +
- "enqPutQueue:{} deqGetQueue:{} deqPutQueue:{} allCongestNum:{} enqExpiredStoreTime:{}",
- storeConfig.getBrokerRole(),
- format(commitReadTimeMs), format(currReadTimeMs), format(currWriteTimeMs), getDequeueBehind(),
- tmpQueueOffset, maxOffsetInQueue - tmpQueueOffset, timerCheckpoint.getMasterTimerQueueOffset() - tmpQueueOffset,
- enqueuePutQueue.size(), dequeueGetQueue.size(), dequeuePutQueue.size(), getAllCongestNum(), format(lastEnqueueButExpiredStoreTime));
- }
- timerMetrics.persist();
+ this.flush();
waitForRunning(storeConfig.getTimerFlushIntervalMs());
} catch (Throwable e) {
TimerMessageStore.LOGGER.error("Error occurred in " + getServiceName(), e);
}
}
TimerMessageStore.LOGGER.info(this.getServiceName() + " service end");
}
+
+ long start = System.currentTimeMillis();
+ long lastSnapshotTime = System.currentTimeMillis();
+
+ public void flush() throws IOException {
+ synchronized (lockWhenFlush) {
+ prepareTimerCheckPoint();
+ timerLog.getMappedFileQueue().flush(0);
+ if (storeConfig.isTimerWheelSnapshotFlush()) {
Review Comment:
It would be better to acquire the lock only when the timerWheelSnapshotFlush is true.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE #9735] Add TimerWheel snapshot mechanism for reliable recovery [rocketmq]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #9736:
URL: https://github.com/apache/rocketmq/pull/9736#issuecomment-3333513332
## [Codecov](https://app.codecov.io/gh/apache/rocketmq/pull/9736?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `28.57143%` with `80 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 48.11%. Comparing base ([`64999c1`](https://app.codecov.io/gh/apache/rocketmq/commit/64999c12bb14bd0b3190630826920aebeaa23914?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`fce55e3`](https://app.codecov.io/gh/apache/rocketmq/commit/fce55e3755fd505602f1c331758bad964d6511f7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/rocketmq/pull/9736?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...va/org/apache/rocketmq/store/timer/TimerWheel.java](https://app.codecov.io/gh/apache/rocketmq/pull/9736?src=pr&el=tree&filepath=store%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fstore%2Ftimer%2FTimerWheel.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL3RpbWVyL1RpbWVyV2hlZWwuamF2YQ==) | 15.62% | [51 Missing and 3 partials :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/9736?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...apache/rocketmq/store/timer/TimerMessageStore.java](https://app.codecov.io/gh/apache/rocketmq/pull/9736?src=pr&el=tree&filepath=store%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fstore%2Ftimer%2FTimerMessageStore.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL3RpbWVyL1RpbWVyTWVzc2FnZVN0b3JlLmphdmE=) | 44.44% | [16 Missing and 4 partials :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/9736?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...ache/rocketmq/store/config/MessageStoreConfig.java](https://app.codecov.io/gh/apache/rocketmq/pull/9736?src=pr&el=tree&filepath=store%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fstore%2Fconfig%2FMessageStoreConfig.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL2NvbmZpZy9NZXNzYWdlU3RvcmVDb25maWcuamF2YQ==) | 50.00% | [6 Missing :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/9736?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## develop #9736 +/- ##
=============================================
- Coverage 48.18% 48.11% -0.07%
+ Complexity 12159 12151 -8
=============================================
Files 1313 1313
Lines 93340 93426 +86
Branches 11962 11976 +14
=============================================
- Hits 44972 44950 -22
- Misses 42790 42891 +101
- Partials 5578 5585 +7
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/rocketmq/pull/9736?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE #9735] Add TimerWheel snapshot mechanism for reliable recovery [rocketmq]
Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin merged PR #9736:
URL: https://github.com/apache/rocketmq/pull/9736
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org