-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
IndexShardRoutingTable
should always be nonempty
#105720
IndexShardRoutingTable
should always be nonempty
#105720
Conversation
There's only one remaining test that creates an empty `IndexShardRoutingTable`. This commit fixes that, and then adds an assertion to enforce that all `IndexShardRoutingTable` instances include at least a primary shard.
Pinging @elastic/es-distributed (Team:Distributed) |
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.
LGTM thanks for cleaning this up.
I think we can also drop the null
check for primary such as this one as a follow-up.
@@ -114,7 +115,8 @@ public class IndexShardRoutingTable { | |||
allShardsStarted = false; | |||
} | |||
} | |||
assert primary != null || shards.isEmpty() : shards; | |||
assert shards.isEmpty() == false : "cannot have an empty shard routing table"; |
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.
The same assertion is already added in the beginning of the method but without the message. Maybe we can merge them by moving the message to the earlier one.
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.
Oh sorry I forgot I added that for some local tests. Removed in 0e08cd5.
Yes good point, there's a few obvious ones, see 0e08cd5. |
There's only one remaining test that creates an empty
IndexShardRoutingTable
. This commit fixes that, and then adds anassertion to enforce that all
IndexShardRoutingTable
instances includeat least a primary shard.