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

Error message referencing the number of shards when in fact the number of replicas is concerned #36234

Closed
AlexisWilke opened this issue Dec 4, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@AlexisWilke
Copy link
Contributor

commented Dec 4, 2018

Elasticsearch version (bin/elasticsearch --version): github master as if Dec 4, 2018

Plugins installed: not applicable

JVM version (java -version): not applicable

OS version (uname -a if on a Unix-like system): not applicable

Description of the problem including expected versus actual behavior:

I would expect the following message when my number of replicas is wrong:

"must specify non-negative number of replicas for index [" + index + "]"

Instead the message says:

"must specify non-negative number of shards for index [" + index + "]"

Which is confusing since we have two parameters (index.number_of_shards and index.replicas and this message applies to the latter.)

Steps to reproduce:

Set a number of replicas which is negative. See this code:

File: elasticsearch/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java
Line: cir. 1138

        Integer maybeNumberOfReplicas = settings.getAsInt(SETTING_NUMBER_OF_REPLICAS, null);
        if (maybeNumberOfReplicas == null) {
            throw new IllegalArgumentException("must specify numberOfReplicas for index [" + index + "]");
        }
        int numberOfReplicas = maybeNumberOfReplicas;
        if (numberOfReplicas < 0) {
            throw new IllegalArgumentException("must specify non-negative number of shards for index [" + index + "]");
        }

Provide logs (if relevant):

I am getting the following error when trying to create a table in express-cassandra. As we can see, it outputs the error I mentioned above. Something to do with the number of replicas, but referenced as shards. I understands that these numbers are linked, but I think that the message is wrong.

status: 400,
displayName: 'BadRequest',
message:
 '[illegal_argument_exception] must specify non-negative number of shards for index [my_search]',
path: '/my_search',
query: {},
body:
 '{"settings":{"keyspace":"my_search"}}',
statusCode: 400,
response:
 '{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"must specify non-negative number of shards for index [my_search]"}],"type":"illegal_argument_exception","reason":"must specify non-negative number of shards for index [my_search]"},"status":400}',
toString: [Function],
toJSON: [Function] }
@elasticmachine

This comment has been minimized.

Copy link

commented Dec 5, 2018

@ywelsch ywelsch added the >bug label Dec 5, 2018

@ywelsch

This comment has been minimized.

Copy link
Contributor

commented Dec 5, 2018

Thanks for reporting this @AlexisWilke. Would you be interested in contributing a patch?

@AlexisWilke

This comment has been minimized.

Copy link
Contributor Author

commented Dec 5, 2018

@ywelsch Okay, will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.