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

LLRC can throw an IllegalCapacityException when selecting nodes. #37739

Closed
jtibshirani opened this issue Jan 23, 2019 · 6 comments
Closed

LLRC can throw an IllegalCapacityException when selecting nodes. #37739

jtibshirani opened this issue Jan 23, 2019 · 6 comments
Labels
>bug :Clients/Java Low Level REST Client Minimal dependencies Java Client for Elasticsearch good first issue low hanging fruit help wanted adoptme

Comments

@jtibshirani
Copy link
Contributor

This issue was originally debugged and reported by a user. It seems that when there are nodes failures, the low-level RestClient may have a race condition around keeping track of the valid nodes. Here's the relevant text from the report:

When too many nodes fail, an IllegalCapacityException is thrown in the low level RestClient.
Defective Code is in line 637:

List<Node> livingNodes = new ArrayList<>(nodeTuple.nodes.size() - blacklist.size());

In some cases nodeTuple.nodes.size() - blacklist.size() < 0, which causes an IllegalCapacityException thrown by the ArrayList constructor.

This causes the RestClient to fail on any further request (including requests issued by the sniffer), thus the client breaks down completely and will not recover.

I think the situation is caused by nodes failing. Then:

  • The sniffer removes a node using RestClient.setNodes(...)
  • There are async requests running on that nodes that fail after the sniffer removed the node
  • Thus, the node (which is not contained in the RestClient.nodeTuple list anymore) is added to the RestClient.blackList during RestClient.onFailure
  • Therefore, a situation where more nodes are blacklisted that nodes are known can occur.
@jtibshirani jtibshirani added >bug :Clients/Java Low Level REST Client Minimal dependencies Java Client for Elasticsearch labels Jan 23, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features

@dakrone dakrone added good first issue low hanging fruit help wanted adoptme labels Jan 23, 2019
@ivange94
Copy link

Hi @jtibshirani is the solution to this just setting the array size to 0 if nodeTuple.nodes.size() - blacklist.size() < 0 ?

@dakrone
Copy link
Member

dakrone commented Jan 23, 2019

Hi @ivange94, yes that is the solution we had in mind for this, something like Math.max(0, nodeTuple.nodes.size() - blacklist.size())

@ivange94
Copy link

ok @dakrone thanks. Let me make the fix.

SivagurunathanV added a commit to SivagurunathanV/elasticsearch that referenced this issue Jan 24, 2019
@SivagurunathanV
Copy link
Contributor

Hi @dakrone
Please find the PR for this issue.

Thanks,
Siva

@dakrone
Copy link
Member

dakrone commented Jan 25, 2019

Resolved by #37821

@dakrone dakrone closed this as completed Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Clients/Java Low Level REST Client Minimal dependencies Java Client for Elasticsearch good first issue low hanging fruit help wanted adoptme
Projects
None yet
Development

No branches or pull requests

5 participants