Skip to content

Commit

Permalink
Fix duplicate mapped file in mutil commitlog store path mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
hexueyuan committed Nov 11, 2024
1 parent 0663136 commit f2759f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private boolean mmapOperation() {
AllocateRequest req = null;
try {
req = this.requestQueue.take();
String fileName = req.getFilePath().substring(req.getFilePath().lastIndexOf("/") + 1);
String fileName = req.getFilePath().substring(req.getFilePath().lastIndexOf(File.separator) + 1);
AllocateRequest expectedRequest = this.requestTable.get(fileName);
if (null == expectedRequest) {
log.warn("this mmap request expired, maybe cause timeout " + req.getFilePath() + " "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -191,7 +193,9 @@ public void testUniqueNextNextMappedFile() throws IOException {
MappedFile mappedFile1 = mappedFileQueue.tryCreateMappedFile(1024);

assertThat(mappedFile1).isNotNull();
assertThat(mappedFile1.getFile().getPath()).isEqualTo("target/unit_test_store/b/00000000000000001024");
assertThat(mappedFile1.getFile().getPath()).isEqualTo(
String.join(File.separator, Arrays.asList("target", "unit_test_store", "b", "00000000000000001024"))
);

mappedFileQueue.shutdown(1000);
mappedFileQueue.destroy();
Expand Down

0 comments on commit f2759f8

Please sign in to comment.