Skip to content

Retry in SnapshotIT Snapshot Abort #54195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void testCleanupRepository() throws IOException {
assertThat(response.result().blobs(), equalTo(0L));
}

public void testCreateSnapshot() throws IOException {
public void testCreateSnapshot() throws Exception {
String repository = "test_repository";
assertTrue(createTestRepository(repository, FsRepository.TYPE, "{\"location\": \".\"}").isAcknowledged());

Expand All @@ -163,12 +163,23 @@ public void testCreateSnapshot() throws IOException {
CreateSnapshotResponse response = createTestSnapshot(request);
assertEquals(waitForCompletion ? RestStatus.OK : RestStatus.ACCEPTED, response.status());
if (waitForCompletion == false) {
// If we don't wait for the snapshot to complete we have to cancel it to not leak the snapshot task
AcknowledgedResponse deleteResponse = execute(
new DeleteSnapshotRequest(repository, snapshot),
highLevelClient().snapshot()::delete, highLevelClient().snapshot()::deleteAsync
);
assertTrue(deleteResponse.isAcknowledged());
// busy assert on the delete because a known race condition could cause the delete request to not see
// the snapshot if delete and snapshot finalization happen at the same time
// See https://github.com/elastic/elasticsearch/issues/53509#issuecomment-603899620 for details
// TODO: Remove busy assert in 7.x+ once this race is fixed
assertBusy(() -> {
// If we don't wait for the snapshot to complete we have to cancel it to not leak the snapshot task
AcknowledgedResponse deleteResponse;
try {
deleteResponse = execute(
new DeleteSnapshotRequest(repository, snapshot),
highLevelClient().snapshot()::delete, highLevelClient().snapshot()::deleteAsync
);
} catch (Exception e) {
throw new AssertionError(e);
}
assertTrue(deleteResponse.isAcknowledged());
});
}
}

Expand Down