@@ -617,12 +617,12 @@ public void onResponse(RepositoryData repositoryData) {
617
617
);
618
618
return ;
619
619
}
620
- cleanOrphanTimestamp (repositoryName , repositoryData );
621
- logger .info ("created snapshot-v2 [{}] in repository [{}]" , repositoryName , snapshotName );
622
620
listener .onResponse (snapshotInfo );
621
+ logger .info ("created snapshot-v2 [{}] in repository [{}]" , repositoryName , snapshotName );
623
622
// For snapshot-v2, we don't allow concurrent snapshots . But meanwhile non-v2 snapshot operations
624
623
// can get queued . This is triggering them.
625
624
runNextQueuedOperation (repositoryData , repositoryName , true );
625
+ cleanOrphanTimestamp (repositoryName , repositoryData );
626
626
}
627
627
628
628
@ Override
@@ -657,8 +657,14 @@ private void cleanOrphanTimestamp(String repoName, RepositoryData repositoryData
657
657
if (orphanPinnedEntities .isEmpty ()) {
658
658
return ;
659
659
}
660
+
660
661
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
+ }
662
668
}
663
669
664
670
private boolean isOrphanPinnedEntity (String repoName , Collection <String > snapshotUUIDs , String pinnedEntity ) {
0 commit comments