yuz10 commented on a change in pull request #3357:
URL: https://github.com/apache/rocketmq/pull/3357#discussion_r713760173
##########
File path: store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
##########
@@ -144,35 +145,39 @@ void deleteExpiredFile(List<MappedFile> files) {
}
}
+
public boolean load() {
File dir = new File(this.storePath);
- File[] files = dir.listFiles();
- if (files != null) {
- // ascending order
- Arrays.sort(files);
- for (File file : files) {
-
- if (file.length() != this.mappedFileSize) {
- log.warn(file + "\t" + file.length()
- + " length not matched message store config value,
please check it manually");
- return false;
- }
+ File[] ls = dir.listFiles();
+ if (ls != null) {
+ return doLoad(Arrays.asList(ls));
+ }
+ return true;
+ }
- try {
- MappedFile mappedFile = new MappedFile(file.getPath(),
mappedFileSize);
-
- mappedFile.setWrotePosition(this.mappedFileSize);
- mappedFile.setFlushedPosition(this.mappedFileSize);
- mappedFile.setCommittedPosition(this.mappedFileSize);
- this.mappedFiles.add(mappedFile);
- log.info("load " + file.getPath() + " OK");
- } catch (IOException e) {
- log.error("load file " + file + " error", e);
- return false;
- }
+ public boolean doLoad(List<File> files) {
+ // ascending order
+ Collections.sort(files);
Review comment:
According to the code :

if paths are a/, b/ then files will be created such as:
a/000000 b/000001 a/000002 b/000003
so sort these can cause wrong order.
a/000000 a/000002 b/000001 b/000003
--
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]