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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]