From 330e71216473f2400e78b34984ecf4dba794c42c Mon Sep 17 00:00:00 2001 From: Suraj Singh Date: Mon, 31 Jul 2023 18:32:48 -0700 Subject: [PATCH] Address review comments Signed-off-by: Suraj Singh --- .../src/main/java/org/opensearch/index/shard/IndexShard.java | 3 ++- server/src/main/java/org/opensearch/index/store/Store.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index 9ce5150faf088..051543a1a30c2 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -4660,7 +4660,8 @@ public void syncSegmentsFromRemoteSegmentStore(boolean overrideLocal, boolean re long processedLocalCheckpoint = Long.parseLong(infosSnapshot.getUserData().get(LOCAL_CHECKPOINT_KEY)); store.commitSegmentInfos(infosSnapshot, processedLocalCheckpoint, processedLocalCheckpoint); Collection currentInfoFiles = infosSnapshot.files(true); - if (recoveryState.getStage() != RecoveryState.Stage.DONE) { + // For recovering shards, clean up un-usable incremental refresh files. + if (state() != IndexShardState.STARTED) { for (String localFile : storeDirectory.listAll()) { if (Store.isAutogenerated(localFile) == false && currentInfoFiles.contains(localFile) == false) { storeDirectory.deleteFile(localFile); diff --git a/server/src/main/java/org/opensearch/index/store/Store.java b/server/src/main/java/org/opensearch/index/store/Store.java index d1ca74948012b..921deae41946a 100644 --- a/server/src/main/java/org/opensearch/index/store/Store.java +++ b/server/src/main/java/org/opensearch/index/store/Store.java @@ -390,7 +390,7 @@ public Map getSegmentMetadataMap(SegmentInfos segment public static RecoveryDiff segmentReplicationDiff(Map source, Map target) { final List identical = new ArrayList<>(); final List different = new ArrayList<>(); - List missing = new ArrayList<>(); + final List missing = new ArrayList<>(); for (StoreFileMetadata value : source.values()) { if (value.name().startsWith(IndexFileNames.SEGMENTS)) { continue;