Skip to content

Commit 92f290e

Browse files
authored
Relax cleanup check in SnapshotStressTestsIT (#106569)
We can't assert no leaked blobs here because today the first cleanup leaves the original `RepositoryData` in place so the second cleanup is not a no-op. Relates #100718 Backport of #100855 to 7.17
1 parent ff776e4 commit 92f290e

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStressTestsIT.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,33 @@ private void startCleaner() {
809809
Releasables.close(releaseAll);
810810
logger.info("--> completed cleanup of [{}]", trackedRepository.repositoryName);
811811
final RepositoryCleanupResult result = cleanupRepositoryResponse.result();
812-
assertThat(Strings.toString(result), result.blobs(), equalTo(0L));
813-
assertThat(Strings.toString(result), result.bytes(), equalTo(0L));
814-
startCleaner();
812+
if (result.bytes() > 0L || result.blobs() > 0L) {
813+
// we could legitimately run into dangling blobs as the result of a shard snapshot failing half-way
814+
// through the snapshot because of a concurrent index-close or -delete. The second round of cleanup on
815+
// the same repository however should always find no more dangling blobs and be a no-op since we block all
816+
// concurrent operations on the repository.
817+
client.admin()
818+
.cluster()
819+
.prepareCleanupRepository(trackedRepository.repositoryName)
820+
.execute(mustSucceed(secondCleanupRepositoryResponse -> {
821+
final RepositoryCleanupResult secondCleanupResult = secondCleanupRepositoryResponse.result();
822+
if (secondCleanupResult.blobs() == 1) {
823+
// The previous cleanup actually leaves behind a stale index-N blob, so this cleanup removes it
824+
// and reports it in its response. When https://github.com/elastic/elasticsearch/pull/100718 is
825+
// fixed the second cleanup will be a proper no-op and we can remove this lenience -- TODO
826+
} else {
827+
assertThat(Strings.toString(secondCleanupResult), secondCleanupResult.blobs(), equalTo(0L));
828+
assertThat(Strings.toString(secondCleanupResult), secondCleanupResult.bytes(), equalTo(0L));
829+
}
830+
Releasables.close(releaseAll);
831+
logger.info("--> completed second cleanup of [{}]", trackedRepository.repositoryName);
832+
startCleaner();
833+
}));
834+
} else {
835+
Releasables.close(releaseAll);
836+
logger.info("--> completed cleanup of [{}]", trackedRepository.repositoryName);
837+
startCleaner();
838+
}
815839
}));
816840

817841
startedCleanup = true;

0 commit comments

Comments
 (0)