Skip to content

Commit 84c924d

Browse files
author
RongtongJin
committed
Add a FileNotFoundException check to allow breaking out of the loop after shutdown
Change-Id: Icc0063544ef91de8b2bd96a80f3829a6922cb0e6
1 parent d82a371 commit 84c924d

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

tieredstore/src/main/java/org/apache/rocketmq/tieredstore/index/IndexStoreFile.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.rocketmq.tieredstore.index;
1818

1919
import com.google.common.base.Stopwatch;
20+
import java.io.FileNotFoundException;
2021
import java.io.IOException;
2122
import java.nio.ByteBuffer;
2223
import java.nio.MappedByteBuffer;
@@ -392,6 +393,8 @@ public ByteBuffer doCompaction() {
392393
buffer = compactToNewFile();
393394
log.debug("IndexStoreFile do compaction, timestamp: {}, file size: {}, cost: {}ms",
394395
this.getTimestamp(), buffer.capacity(), stopwatch.elapsed(TimeUnit.MICROSECONDS));
396+
} catch (FileNotFoundException e) {
397+
throw new RuntimeException(e);
395398
} catch (Exception e) {
396399
log.error("IndexStoreFile do compaction, timestamp: {}, cost: {}ms",
397400
this.getTimestamp(), stopwatch.elapsed(TimeUnit.MICROSECONDS), e);

tieredstore/src/main/java/org/apache/rocketmq/tieredstore/index/IndexStoreService.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,15 +417,19 @@ public void shutdown() {
417417
@Override
418418
public void run() {
419419
while (!this.isStopped()) {
420-
long expireTimestamp = System.currentTimeMillis()
421-
- TimeUnit.HOURS.toMillis(storeConfig.getTieredStoreFileReservedTime());
422-
this.destroyExpiredFile(expireTimestamp);
423-
IndexFile indexFile = this.getNextSealedFile();
424-
if (indexFile != null) {
425-
if (this.doCompactThenUploadFile(indexFile)) {
426-
this.setCompactTimestamp(indexFile.getTimestamp());
427-
continue;
420+
try {
421+
long expireTimestamp = System.currentTimeMillis()
422+
- TimeUnit.HOURS.toMillis(storeConfig.getTieredStoreFileReservedTime());
423+
this.destroyExpiredFile(expireTimestamp);
424+
IndexFile indexFile = this.getNextSealedFile();
425+
if (indexFile != null) {
426+
if (this.doCompactThenUploadFile(indexFile)) {
427+
this.setCompactTimestamp(indexFile.getTimestamp());
428+
continue;
429+
}
428430
}
431+
} catch (Throwable e) {
432+
log.error("IndexStoreService running error", e);
429433
}
430434
this.waitForRunning(TimeUnit.SECONDS.toMillis(10));
431435
}

0 commit comments

Comments
 (0)