-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Fix BlobStoreRepositoryCleanupIT Leaking Futures #69446
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 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e612bd5
Fix BlobStoreRepositoryCleanupIT Leaking Futures
original-brownbear aff8e3e
fix exception
original-brownbear 099ecd0
Merge remote-tracking branch 'elastic/master' into 69343
original-brownbear 104aa88
CR: fix comment and proper assertion on throwing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,9 @@ | |
*/ | ||
package org.elasticsearch.repositories.blobstore; | ||
|
||
import org.elasticsearch.action.ActionFuture; | ||
import org.elasticsearch.action.ActionRunnable; | ||
import org.elasticsearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryResponse; | ||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; | ||
import org.elasticsearch.action.support.PlainActionFuture; | ||
import org.elasticsearch.cluster.RepositoryCleanupInProgress; | ||
|
@@ -26,7 +28,7 @@ | |
public class BlobStoreRepositoryCleanupIT extends AbstractSnapshotIntegTestCase { | ||
|
||
public void testMasterFailoverDuringCleanup() throws Exception { | ||
startBlockedCleanup("test-repo"); | ||
final ActionFuture<CleanupRepositoryResponse> cleanupFuture = startBlockedCleanup("test-repo"); | ||
|
||
final int nodeCount = internalCluster().numDataAndMasterNodes(); | ||
logger.info("--> stopping master node"); | ||
|
@@ -37,10 +39,12 @@ public void testMasterFailoverDuringCleanup() throws Exception { | |
logger.info("--> wait for cleanup to finish and disappear from cluster state"); | ||
awaitClusterState(state -> | ||
state.custom(RepositoryCleanupInProgress.TYPE, RepositoryCleanupInProgress.EMPTY).hasCleanupInProgress() == false); | ||
|
||
cleanupFuture.get(); | ||
} | ||
|
||
public void testRepeatCleanupsDontRemove() throws Exception { | ||
final String masterNode = startBlockedCleanup("test-repo"); | ||
final ActionFuture<CleanupRepositoryResponse> cleanupFuture = startBlockedCleanup("test-repo"); | ||
|
||
logger.info("--> sending another cleanup"); | ||
assertFutureThrows(client().admin().cluster().prepareCleanupRepository("test-repo").execute(), IllegalStateException.class); | ||
|
@@ -51,14 +55,20 @@ public void testRepeatCleanupsDontRemove() throws Exception { | |
assertTrue(cleanup.hasCleanupInProgress()); | ||
|
||
logger.info("--> unblocking master node"); | ||
unblockNode("test-repo", masterNode); | ||
unblockNode("test-repo", internalCluster().getMasterName()); | ||
|
||
logger.info("--> wait for cleanup to finish and disappear from cluster state"); | ||
awaitClusterState(state -> | ||
state.custom(RepositoryCleanupInProgress.TYPE, RepositoryCleanupInProgress.EMPTY).hasCleanupInProgress() == false); | ||
|
||
try { | ||
cleanupFuture.get(); | ||
} catch (ExecutionException e) { | ||
// ignored and expected | ||
} | ||
} | ||
|
||
private String startBlockedCleanup(String repoName) throws Exception { | ||
private ActionFuture<CleanupRepositoryResponse> startBlockedCleanup(String repoName) throws Exception { | ||
logger.info("--> starting two master nodes and one data node"); | ||
internalCluster().startMasterOnlyNodes(2); | ||
internalCluster().startDataOnlyNodes(1); | ||
|
@@ -80,13 +90,16 @@ private String startBlockedCleanup(String repoName) throws Exception { | |
blockMasterFromFinalizingSnapshotOnIndexFile(repoName); | ||
|
||
logger.info("--> starting repository cleanup"); | ||
client().admin().cluster().prepareCleanupRepository(repoName).execute(); | ||
// not running from a non-master client because shutting down a master while a request to it is pending might result in the future | ||
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. s/not running/running/ ? 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. ++ |
||
// never completing | ||
final ActionFuture<CleanupRepositoryResponse> future = | ||
internalCluster().nonMasterClient().admin().cluster().prepareCleanupRepository(repoName).execute(); | ||
|
||
final String masterNode = internalCluster().getMasterName(); | ||
waitForBlock(masterNode, repoName); | ||
awaitClusterState(state -> | ||
state.custom(RepositoryCleanupInProgress.TYPE, RepositoryCleanupInProgress.EMPTY).hasCleanupInProgress()); | ||
return masterNode; | ||
return future; | ||
} | ||
|
||
public void testCleanupOldIndexN() throws ExecutionException, InterruptedException { | ||
|
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.
Can't we be more specific about the exception that we expect here?
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.
Yea definitely, sorry for the laziness, made it a proper specific assertion now :)
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.
No problem! :)