Skip to content

Commit bcd8268

Browse files
author
guyinyou
committed
fix
Change-Id: I97968a6b87d55c73ce871b3522c67b8b543d6eb2
1 parent fce55e3 commit bcd8268

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public class MessageStoreConfig {
8181
private boolean timerInterceptDelayLevel = false;
8282
private int timerMaxDelaySec = 3600 * 24 * 3;
8383
private boolean timerWheelSnapshotFlush = false;
84-
private boolean timerWheelDefaultFlush = true;
8584
private boolean timerWheelEnable = true;
8685

8786
/**
@@ -1750,14 +1749,6 @@ public boolean isTimerWarmEnable() {
17501749
return timerWarmEnable;
17511750
}
17521751

1753-
public boolean isTimerWheelDefaultFlush() {
1754-
return timerWheelDefaultFlush;
1755-
}
1756-
1757-
public void setTimerWheelDefaultFlush(boolean timerWheelDefaultFlush) {
1758-
this.timerWheelDefaultFlush = timerWheelDefaultFlush;
1759-
}
1760-
17611752
public boolean isTimerWheelSnapshotFlush() {
17621753
return timerWheelSnapshotFlush;
17631754
}

store/src/main/java/org/apache/rocketmq/store/timer/TimerMessageStore.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,13 @@ public TimerMessageStore(final MessageStore messageStore, final MessageStoreConf
179179
long snapOffset = -1;
180180
if (storeConfig.isTimerWheelSnapshotFlush()) {
181181
snapOffset = TimerWheel.getMaxSnapshotFlag(timerWheelPath);
182-
// correct recover offset
183-
timerCheckpoint.setLastTimerLogFlushPos(snapOffset);
184-
LOGGER.info("found timerWheel snapshot offset {}", snapOffset);
182+
if (snapOffset > 0) {
183+
// correct recover offset
184+
timerCheckpoint.setLastTimerLogFlushPos(snapOffset);
185+
LOGGER.info("found timerWheel snapshot offset {}", snapOffset);
186+
} else {
187+
LOGGER.info("not found timerWheel snapshot", snapOffset);
188+
}
185189
}
186190
this.timerWheel = new TimerWheel(
187191
timerWheelPath, this.slotsTotal, precisionMs, snapOffset);
@@ -1836,15 +1840,12 @@ public void flush() throws IOException {
18361840
synchronized (lockWhenFlush) {
18371841
prepareTimerCheckPoint();
18381842
timerLog.getMappedFileQueue().flush(0);
1839-
if (storeConfig.isTimerWheelDefaultFlush()) {
1840-
timerWheel.flush();
1843+
if (System.currentTimeMillis() - lastSnapshotTime > storeConfig.getTimerWheelSnapshotIntervalMs()) {
1844+
lastSnapshotTime = System.currentTimeMillis();
1845+
timerWheel.backup(timerLog.getMappedFileQueue().getFlushedWhere());
1846+
timerCheckpoint.flush();
18411847
}
18421848
}
1843-
if (System.currentTimeMillis() - lastSnapshotTime > storeConfig.getTimerWheelSnapshotIntervalMs()) {
1844-
lastSnapshotTime = System.currentTimeMillis();
1845-
timerWheel.backup(timerLog.getMappedFileQueue().getFlushedWhere());
1846-
timerCheckpoint.flush();
1847-
}
18481849
if (System.currentTimeMillis() - start > storeConfig.getTimerProgressLogIntervalMs()) {
18491850
start = System.currentTimeMillis();
18501851
long tmpQueueOffset = currQueueOffset;

0 commit comments

Comments
 (0)