Skip to content

Commit

Permalink
Remove unnecessary catch for NoSuchFileException.
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Handalian <handalm@amazon.com>
  • Loading branch information
mch2 committed Aug 1, 2023
1 parent 15b28eb commit 7d26193
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public synchronized GatedCloseable<SegmentInfos> getSegmentInfosSnapshot() {
final SegmentInfos latestSegmentInfos = getLatestSegmentInfos();
// incref all files
try {
final Collection<String> files = latestSegmentInfos.files(true);
final Collection<String> files = latestSegmentInfos.files(false);
store.incRefFileDeleter(files);
return new GatedCloseable<>(latestSegmentInfos, () -> store.decRefFileDeleter(files));
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,12 @@ public void updateShardState(
assert newRouting.primary() && currentRouting.primary() == false;
resetEngineToGlobalCheckpoint();
}

replicationTracker.activatePrimaryMode(getLocalCheckpoint());

if (indexSettings.isSegRepEnabled()) {
// force publish a checkpoint now that shard is in primary mode.
if (checkpointPublisher != null) {
// force publish a checkpoint once in primary mode so that replicas not caught up to previous primary
// are brought up to date.
checkpointPublisher.publish(this, getLatestReplicationCheckpoint());
}

Expand Down
4 changes: 0 additions & 4 deletions server/src/main/java/org/opensearch/index/store/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -824,10 +824,6 @@ private void cleanupFiles(Collection<String> filesToConsiderForCleanup, String r
try {
directory.deleteFile(reason, existingFile);
} catch (IOException ex) {
if (ex instanceof NoSuchFileException) {
// file doesn't exist, nothing to do.
return;
}
if (existingFile.startsWith(IndexFileNames.SEGMENTS) || existingFile.startsWith(CORRUPTED_MARKER_NAME_PREFIX)) {
// TODO do we need to also fail this if we can't delete the pending commit file?
// if one of those files can't be deleted we better fail the cleanup otherwise we might leave an old commit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,7 @@ public void testGetSegmentInfosSnapshotPreservesFilesUntilRelease() throws Excep
final Store nrtEngineStore = createStore(REMOTE_STORE_INDEX_SETTINGS, newDirectory());
final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore, settings)
) {
List<Engine.Operation> operations = generateHistoryOnReplica(
between(10, 20),
randomBoolean(),
randomBoolean(),
randomBoolean()
);
List<Engine.Operation> operations = generateHistoryOnReplica(between(5, 10), randomBoolean(), randomBoolean(), randomBoolean());
for (Engine.Operation op : operations) {
applyOperation(engine, op);
applyOperation(nrtEngine, op);
Expand All @@ -405,12 +400,12 @@ public void testGetSegmentInfosSnapshotPreservesFilesUntilRelease() throws Excep
nrtEngine.updateSegments(engine.getLatestSegmentInfos());
assertEquals(engine.getLatestSegmentInfos(), nrtEngine.getLatestSegmentInfos());
final GatedCloseable<SegmentInfos> snapshot = nrtEngine.getSegmentInfosSnapshot();
final Collection<String> replica_snapshotFiles = snapshot.get().files(true);
final Collection<String> replica_snapshotFiles = snapshot.get().files(false);
List<String> replicaFiles = List.of(nrtEngine.store.directory().listAll());

// merge primary down to 1 segment
engine.forceMerge(true, 1, false, false, false, UUIDs.randomBase64UUID());
final Collection<String> files = engine.getLatestSegmentInfos().files(true);
final Collection<String> files = engine.getLatestSegmentInfos().files(false);

// copy new segments in and load reader.
for (String file : files) {
Expand Down

0 comments on commit 7d26193

Please sign in to comment.