Skip to content

Commit f1c98a4

Browse files
authored
Do orphan timestamp cleanup before completing the snapshot (#16365)
Signed-off-by: Gaurav Bafna <gbbafna@amazon.com>
1 parent 9096aee commit f1c98a4

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

server/src/main/java/org/opensearch/snapshots/SnapshotsService.java

+3-9
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,12 @@ public void onResponse(RepositoryData repositoryData) {
617617
);
618618
return;
619619
}
620-
listener.onResponse(snapshotInfo);
620+
cleanOrphanTimestamp(repositoryName, repositoryData);
621621
logger.info("created snapshot-v2 [{}] in repository [{}]", repositoryName, snapshotName);
622+
listener.onResponse(snapshotInfo);
622623
// For snapshot-v2, we don't allow concurrent snapshots . But meanwhile non-v2 snapshot operations
623624
// can get queued . This is triggering them.
624625
runNextQueuedOperation(repositoryData, repositoryName, true);
625-
cleanOrphanTimestamp(repositoryName, repositoryData);
626626
}
627627

628628
@Override
@@ -657,14 +657,8 @@ private void cleanOrphanTimestamp(String repoName, RepositoryData repositoryData
657657
if (orphanPinnedEntities.isEmpty()) {
658658
return;
659659
}
660-
661660
logger.info("Found {} orphan timestamps. Cleaning it up now", orphanPinnedEntities.size());
662-
if (tryEnterRepoLoop(repoName)) {
663-
deleteOrphanTimestamps(pinnedEntities, orphanPinnedEntities);
664-
leaveRepoLoop(repoName);
665-
} else {
666-
logger.info("Concurrent snapshot create/delete is happening. Skipping clean up of orphan timestamps");
667-
}
661+
deleteOrphanTimestamps(pinnedEntities, orphanPinnedEntities);
668662
}
669663

670664
private boolean isOrphanPinnedEntity(String repoName, Collection<String> snapshotUUIDs, String pinnedEntity) {

0 commit comments

Comments
 (0)