-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
With #30942 (add is-write-index to aliases) and #31520, we allow an alias to point to multiple indices when
writing/deleting documents. This means that we will resolve the alias to the "write index" specified in alias metadata.
This presents a problem when requests resolve routing values against aliases. Historically, it was clear
that if an alias specified routing values, those would be used, instead of the index's. With, potentially, different aliases having different routing values, it isn't clear which routing value an index request should use.
The code in Metadata that needs modifying:
https://github.com/elastic/elasticsearch/blob/4761a1f/server/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java#L479-L491
public String resolveIndexRouting(@Nullable String routing, String aliasOrIndex) {
if (aliasOrIndex == null) {
return routing;
}
AliasOrIndex result = getAliasAndIndexLookup().get(aliasOrIndex);
if (result == null || result.isAlias() == false) {
return routing;
}
AliasOrIndex.Alias alias = (AliasOrIndex.Alias) result;
if (result.getIndices().size() > 1) {
rejectSingleIndexOperation(aliasOrIndex, result);
}
There are a few solutions
- when resolving routing within write operations (ones that require a write index), aliases matching multiple indices can have their routing values ignored. This means the default routing value is used, and no exception is thrown.
- We can throw an exception if an alias points to multiple indices and any one of the aliases specifies their own routing values. Otherwise, we have nothing to look for, so it is safe to have an alias point to multiple indices, and simply return the default routing value passed into the method.
- others?
cc/ @bleskes