-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Disable auto-expand functionality for stateless indices #108797
base: main
Are you sure you want to change the base?
Disable auto-expand functionality for stateless indices #108797
Conversation
ddf7f17
to
76e6ffa
Compare
Replicas are automatically managed in stateless, hence auto-expand replicas needs to be disabled for stateless indices in order for it not to conflict with the automatic management of replicas for indices. As a result, stateless indices won't see auto-expand take any effect due to applying auto-expand replicas from the ES codebase. There is an edge-case for indices that do set number of replicas to 0 manually as well as auto_expand_replicas as part of index settings: in that case we force such value to be 1 rather than 0.
7cebdc8
to
35da6d5
Compare
indexMetadata.getSettings().get(ExistingShardsAllocator.EXISTING_SHARDS_ALLOCATOR_SETTING.getKey()), | ||
"stateless" | ||
)) { | ||
if (indexMetadata.getNumberOfReplicas() == 0) { |
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.
I opened #108994 to at least partially address this situation, where we create indices providing auto_expand_replicas
config as well as number_of_replicas
, but that won't cover all cases. There's one case of the enrich index that gets created with number of replicas set to 0, and only later updated to get auto expanded.
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.
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, I think it would be great though if we had any kind of unit test for `AutoExpandReplicas#getAutoExpandReplicaChanges" though, I would have expected a change like this to require at least some test adaption. I haven't looked into how difficult it is to add something, but since the method is public it should be possible to pass in some mocks at least for the cases changed here.
Replicas are automatically managed in stateless, this commit disabled auto-expand replicas for stateless indices. As a result, stateless indices won't see auto-expand take any effect. Such indices will have their replicas auto-managed like any other index.
Note: the auto-expand functionality is already disabled for stateless indices, by always returning 1 as desired number of replicas. What this PR does is skipping stateless indices entirely, so that we don't make any decision around auto-expanding, instead of forcing 1. The end result will be the same in terms of number of replicas, because 0 will be rewritten to 1 anyways, but values that differ from 0 will be left as-is instead of rewritten to 1 at all times.