Skip to content

Commit 0c95d2a

Browse files
committed
Revert "Do orphan timestamp cleanup before completing the snapshot (opensearch-project#16365)"
This reverts commit f1c98a4.
1 parent 257f2ec commit 0c95d2a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

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

628628
@Override
@@ -657,8 +657,14 @@ private void cleanOrphanTimestamp(String repoName, RepositoryData repositoryData
657657
if (orphanPinnedEntities.isEmpty()) {
658658
return;
659659
}
660+
660661
logger.info("Found {} orphan timestamps. Cleaning it up now", orphanPinnedEntities.size());
661-
deleteOrphanTimestamps(pinnedEntities, orphanPinnedEntities);
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+
}
662668
}
663669

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

0 commit comments

Comments
 (0)