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

Metadata cannot reject aliases pointing to multiple indices when resolving routing #31936

Closed
talevy opened this issue Jul 10, 2018 · 2 comments
Closed
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates

Comments

@talevy
Copy link
Contributor

talevy commented Jul 10, 2018

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

  1. 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.
  2. 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.
  3. others?

cc/ @bleskes

@talevy talevy added the :Data Management/Indices APIs APIs to create and manage indices and templates label Jul 10, 2018
@talevy talevy self-assigned this Jul 10, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@talevy
Copy link
Contributor Author

talevy commented Jul 19, 2018

After discussion on #31520

the following was settled:

  1. If write index exists, resolve to routing of the alias from the AliasMetadata on that index. If no write index exists, throw exception. Effect of this is that if there if an alias with routing points to only one index (with no is_write_index set), the existing behavior is preserved.
  2. all read operations are left untouched

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates
Projects
None yet
Development

No branches or pull requests

2 participants