Skip to content
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

Fix testRecoveryIsCancelledAfterDeletingTheIndex #76644

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 @@ -475,12 +475,6 @@ public void testRecoveryIsCancelledAfterDeletingTheIndex() throws Exception {
createSnapshot(repoName, "snap", Collections.singletonList(indexName));

String targetNode = internalCluster().startDataOnlyNode();
assertAcked(
client().admin().indices().prepareUpdateSettings(indexName)
.setSettings(Settings.builder()
.put("index.routing.allocation.require._name", targetNode)).get()
);

MockTransportService targetMockTransportService =
(MockTransportService) internalCluster().getInstance(TransportService.class, targetNode);

Expand All @@ -496,6 +490,12 @@ public void testRecoveryIsCancelledAfterDeletingTheIndex() throws Exception {
}
);

assertAcked(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the difference between these two snippets is that we have to register a send behaviour before updating indices settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, if we update settings first, we risk the recovery starting or completing before we add the send behavior. That makes the recoverSnapshotFileRequestReceived.await() a few lines down never complete, failing the test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had an inadvertent race between the call to addRequestHandlingBehavior and the end of the recovery triggered by the update settings call - if the recovery completed before we got around to adding the request handler then we'd never count down the recoverSnapshotFileRequestReceived latch. The fix is to hook into the transport service before we even start the recovery.

client().admin().indices().prepareUpdateSettings(indexName)
.setSettings(Settings.builder()
.put("index.routing.allocation.require._name", targetNode)).get()
);

recoverSnapshotFileRequestReceived.await();

assertAcked(client().admin().indices().prepareDelete(indexName).get());
Expand Down