Skip to content

Commit

Permalink
Handle NoSuchFileException when attempting to delete decref'd files.
Browse files Browse the repository at this point in the history
To avoid divergent logic with remote store, we always incref/decref the segmentinfos.files(true) which includes the segments_n file.
Decref to 0 will attempt to delete the file from the store and its possible this _n file does not yet exist. This change will ignore if we get a noSuchFile while attempting to delete.

Signed-off-by: Marc Handalian <[email protected]>
  • Loading branch information
mch2 committed Jul 27, 2023
1 parent fe6a88e commit 8476d5d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/src/main/java/org/opensearch/index/store/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,10 @@ 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

0 comments on commit 8476d5d

Please sign in to comment.