-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Deduplicate Shard Started Requests #82089
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a8e758f
Deduplicate Shard Started Requests
original-brownbear 67d1fff
Merge remote-tracking branch 'elastic/master' into 81628
original-brownbear ca40e0c
trivial test and dedup cleanup on failover
original-brownbear fc1b768
udpate comment + enhance test
original-brownbear File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,7 +149,7 @@ public void tearDown() throws Exception { | |
| clusterService.close(); | ||
| transportService.close(); | ||
| super.tearDown(); | ||
| assertThat(shardStateAction.remoteShardFailedCacheSize(), equalTo(0)); | ||
| assertThat(shardStateAction.remoteShardRequestsInFlight(), equalTo(0)); | ||
| } | ||
|
|
||
| @AfterClass | ||
|
|
@@ -382,6 +382,40 @@ public void onFailure(Exception e) { | |
| assertThat(transport.capturedRequests(), arrayWithSize(0)); | ||
| } | ||
|
|
||
| public void testDeduplicateRemoteShardStarted() throws InterruptedException { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we either add a test or randomly clear the deduplicator here and then validate we see two requests at the end?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ++ done |
||
| final String index = "test"; | ||
| setState(clusterService, ClusterStateCreationUtils.stateWithActivePrimary(index, true, randomInt(5))); | ||
| ShardRouting startedShard = getRandomShardRouting(index); | ||
| int numListeners = between(1, 100); | ||
| CountDownLatch latch = new CountDownLatch(numListeners); | ||
| long primaryTerm = randomLongBetween(1, Long.MAX_VALUE); | ||
| int expectedRequests = 1; | ||
| for (int i = 0; i < numListeners; i++) { | ||
| if (rarely() && i > 0) { | ||
| expectedRequests++; | ||
| shardStateAction.clearRemoteShardRequestDeduplicator(); | ||
| } | ||
| shardStateAction.shardStarted(startedShard, primaryTerm, "started", ShardLongFieldRange.EMPTY, new ActionListener<>() { | ||
| @Override | ||
| public void onResponse(Void aVoid) { | ||
| latch.countDown(); | ||
| } | ||
|
|
||
| @Override | ||
| public void onFailure(Exception e) { | ||
| latch.countDown(); | ||
| } | ||
| }); | ||
| } | ||
| CapturingTransport.CapturedRequest[] capturedRequests = transport.getCapturedRequestsAndClear(); | ||
| assertThat(capturedRequests, arrayWithSize(expectedRequests)); | ||
| for (int i = 0; i < expectedRequests; i++) { | ||
| transport.handleResponse(capturedRequests[i].requestId, TransportResponse.Empty.INSTANCE); | ||
| } | ||
| latch.await(); | ||
| assertThat(transport.capturedRequests(), arrayWithSize(0)); | ||
| } | ||
|
|
||
| public void testRemoteShardFailedConcurrently() throws Exception { | ||
| final String index = "test"; | ||
| final AtomicBoolean shutdown = new AtomicBoolean(false); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we call this from multiple threads, there is a bit of best-effort over this method, I think that is worth documenting.
For instance, this may clear out a remote shard failed request deduplication to the new master in edge cases. This does no real harm, since we still protect the master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ added