Skip to content

Commit

Permalink
Temp revert
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <[email protected]>
  • Loading branch information
sachinpkale committed Oct 20, 2024
1 parent 0c95d2a commit f34484e
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions server/src/main/java/org/opensearch/snapshots/SnapshotsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -646,24 +646,32 @@ public TimeValue timeout() {
}

private void cleanOrphanTimestamp(String repoName, RepositoryData repositoryData) {
Collection<String> snapshotUUIDs = repositoryData.getSnapshotIds().stream().map(SnapshotId::getUUID).collect(Collectors.toSet());
Map<String, List<Long>> pinnedEntities = RemoteStorePinnedTimestampService.getPinnedEntities();
boolean enterRepo = false;
try {
if (tryEnterRepoLoop(repoName) == false) {
logger.error("Concurrent snapshot . Bailing out");
return;
}
enterRepo = true;
Collection<String> snapshotUUIDs = repositoryData.getSnapshotIds().stream().map(SnapshotId::getUUID).collect(Collectors.toSet());
Map<String, List<Long>> pinnedEntities = RemoteStorePinnedTimestampService.getPinnedEntities();

List<String> orphanPinnedEntities = pinnedEntities.keySet()
.stream()
.filter(pinnedEntity -> isOrphanPinnedEntity(repoName, snapshotUUIDs, pinnedEntity))
.collect(Collectors.toList());
List<String> orphanPinnedEntities = pinnedEntities.keySet()
.stream()
.filter(pinnedEntity -> isOrphanPinnedEntity(repoName, snapshotUUIDs, pinnedEntity))
.collect(Collectors.toList());

if (orphanPinnedEntities.isEmpty()) {
return;
}
if (orphanPinnedEntities.isEmpty()) {
return;
}

logger.info("Found {} orphan timestamps. Cleaning it up now", orphanPinnedEntities.size());
if (tryEnterRepoLoop(repoName)) {
// Repo data old
logger.info("Found {} orphan timestamps. Cleaning it up now", orphanPinnedEntities.size());
deleteOrphanTimestamps(pinnedEntities, orphanPinnedEntities);
leaveRepoLoop(repoName);
} else {
logger.info("Concurrent snapshot create/delete is happening. Skipping clean up of orphan timestamps");
} finally {
if (enterRepo) {
leaveRepoLoop(repoName);
}
}
}

Expand Down

0 comments on commit f34484e

Please sign in to comment.