diff --git a/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java b/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java index 51aec1c7045e3..dfbe40e3a47db 100644 --- a/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java +++ b/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java @@ -251,18 +251,7 @@ public IndexOutput createOutput(String name, IOContext context) throws IOExcepti */ @Override public void sync(Collection names) throws IOException { - ensureOpen(); - logger.trace("Composite Directory[{}]: sync() called {}", this::toString, () -> names); - Set remoteFiles = Set.of(getRemoteFiles()); - Set localFilesHavingBlocks = Arrays.stream(listLocalFiles()) - .filter(FileTypeUtils::isBlockFile) - .map(file -> file.substring(0, file.indexOf(BLOCK_FILE_IDENTIFIER))) - .collect(Collectors.toSet()); - Collection fullFilesToSync = names.stream() - .filter(name -> (remoteFiles.contains(name) == false) && (localFilesHavingBlocks.contains(name) == false)) - .collect(Collectors.toList()); - logger.trace("Composite Directory[{}]: Synced files : {}", this::toString, () -> fullFilesToSync); - localDirectory.sync(fullFilesToSync); + logger.trace("Composite Directory[{}]: sync() called {}; Skipping sync", this::toString, () -> names); } /** diff --git a/server/src/test/java/org/opensearch/index/store/CompositeDirectoryTests.java b/server/src/test/java/org/opensearch/index/store/CompositeDirectoryTests.java index 9cbc2fdd12c97..276d2097df7d3 100644 --- a/server/src/test/java/org/opensearch/index/store/CompositeDirectoryTests.java +++ b/server/src/test/java/org/opensearch/index/store/CompositeDirectoryTests.java @@ -29,9 +29,7 @@ import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.Arrays; -import java.util.Collection; import java.util.HashSet; -import java.util.List; @ThreadLeakFilters(filters = CleanerDaemonThreadLeakFilter.class) public class CompositeDirectoryTests extends BaseRemoteSegmentStoreDirectoryTests { @@ -126,21 +124,6 @@ public void testCreateOutput() throws IOException { assertNotNull(fileCache.get(localDirectory.getDirectory().resolve(NEW_FILE))); } - public void testSync() throws IOException { - // All the files in the below list are present either locally or on remote, so sync should work as expected - Collection names = List.of("_0.cfe", "_0.cfs", "_0.si", "_1.cfe", "_2.cfe", "segments_1"); - compositeDirectory.sync(names); - // Deleting file _1.cfe and then adding its blocks locally so that full file is not present but block files are present in local - // State of _1.cfe file after these operations - not present in remote, full file not present locally but blocks present in local - compositeDirectory.deleteFile("_1.cfe"); - addFilesToDirectory(new String[] { "_1.cfe_block_0", "_1.cfe_block_2" }); - // Sync should work as expected since blocks are present in local - compositeDirectory.sync(List.of("_1.cfe")); - // Below list contains a non-existent file, hence will throw an error - Collection names1 = List.of("_0.cfe", "_0.cfs", "_0.si", "_1.cfe", "_2.cfe", "segments_1", "non_existent_file"); - assertThrows(NoSuchFileException.class, () -> compositeDirectory.sync(names1)); - } - public void testRename() throws IOException { // Rename should work as expected for file present in directory assertTrue(existsInCompositeDirectory(FILE_PRESENT_LOCALLY));