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

ActiveShardCount should not fail when closing the index #35936

Merged
merged 3 commits into from Nov 29, 2018

Conversation

tlrx
Copy link
Member

@tlrx tlrx commented Nov 27, 2018

The ActiveShardCount is used by cluster state observers to wait for a given number of shards to be active before returning to the caller. The current implementation does not work when an index is closed while an observer is waiting on shards to be active. In this case, a NPE is thrown and the observer is never notified that the shards won't become active.

This pull request fixes the ActiveShardCount.enoughShardsActive() so that it returns "OK" when an index is closed, similarly to what is done when an index is deleted. It also adds a test that would have fail with the previous behavior.

@tlrx tlrx added >bug v7.0.0 :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. v6.6.0 labels Nov 27, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

Copy link
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

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

Good catch. I've added a comment suggesting a different kind of test.

@@ -317,6 +322,26 @@ public void testOpenWaitingForActiveShardsFailed() throws Exception {
ensureGreen("test");
}

public void testCloseUnassignedIndex() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's try to avoid writing these kind of integration tests that simulate a complicated series of steps to reproduce a corner case. Maybe instead add a unit test to ActiveShardCountTests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe instead add a unit test to ActiveShardCountTests?

Ok

Let's try to avoid writing these kind of integration tests that simulate a complicated series of steps to reproduce a corner case.

Well, I've been surprised that we didn't have any integration test that closes an unassigned index so I added one. On the other hand this won't play well with replicated closed indices so it's better to not add it, I agree.

@tlrx
Copy link
Member Author

tlrx commented Nov 28, 2018

Thanks @ywelsch, I pushed 6084e4d.

Copy link
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

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

LGTM

@tlrx tlrx merged commit 0967620 into elastic:master Nov 29, 2018
@tlrx tlrx deleted the wait-for-active-shards-on-close branch November 29, 2018 08:08
@tlrx
Copy link
Member Author

tlrx commented Nov 29, 2018

Thanks @ywelsch

tlrx added a commit that referenced this pull request Nov 29, 2018
The ActiveShardCount is used by cluster state observers to wait for a 
given number of shards to be active before returning to the caller. The 
current implementation does not work when an index is closed while an 
observer is waiting on shards to be active. In this case, a NPE is thrown 
and the observer is never notified that the shards won't become active.

This commit fixes the ActiveShardCount.enoughShardsActive() so that it 
does not fail when an index is closed, similarly to what is done when an 
index is deleted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. v6.6.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants