diff --git a/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java b/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java index 9079d78502e..0bc70642fe9 100644 --- a/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java +++ b/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java @@ -247,11 +247,18 @@ public boolean doLoad(List files) { // ascending order files.sort(Comparator.comparing(File::getName)); - for (File file : files) { + for (int i = 0; i < files.size(); i++) { + File file = files.get(i); if (file.isDirectory()) { continue; } + if (file.length() == 0 && i == files.size() - 1) { + boolean ok = file.delete(); + log.warn("{} size is 0, auto delete. is_ok: {}", file, ok); + continue; + } + if (file.length() != this.mappedFileSize) { log.warn(file + "\t" + file.length() + " length not matched message store config value, please check it manually");