Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Suraj Singh <surajrider@gmail.com>
  • Loading branch information
dreamer-89 committed Apr 12, 2023
1 parent 6eb4068 commit ab54956
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions server/src/main/java/org/opensearch/index/store/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -814,13 +814,11 @@ private void cleanupFiles(String reason)
* This method is used to clean up un referenced files by reader manager.
* @throws IOException when there is an IO error in clean up.
*/
private void cleanUnReferencedReaderManagerFiles() throws IOException {
private void cleanUnReferencedFiles() throws IOException {
assert indexSettings.isSegRepEnabled();
// fetch a snapshot from the latest on disk Segments_N file. This can be behind
// the passed in local in memory snapshot, so we want to ensure files it references are not removed.
metadataLock.writeLock().lock();
try (Lock writeLock = directory.obtainLock(IndexWriter.WRITE_LOCK_NAME)) {
cleanupFiles("After commit");
cleanupFiles("Segrep cleanup after commit");
} finally {
metadataLock.writeLock().unlock();
}
Expand Down Expand Up @@ -1916,7 +1914,7 @@ public void decRefFileDeleter(Collection<String> files) {
if (this.indexSettings.isSegRepEnabled()) {
this.replicaFileTracker.decRef(files);
try {
cleanUnReferencedReaderManagerFiles();
cleanUnReferencedFiles();
} catch (IOException e) {
logger.error("Error cleaning files", e);
}
Expand Down

0 comments on commit ab54956

Please sign in to comment.