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

Fix handling indices stats request when all shards are missing #20464

Closed
wants to merge 1 commit into from

Conversation

areek
Copy link
Contributor

@areek areek commented Sep 14, 2016

Currently, when an index exists in the cluster state but has no shards for reporting stats,
the missing stats object cause a NullPointerException when requesting the indices stats.
In this commit missing stats object for an index are initialized as empty stats instead
of null, honoring the stats flags set in the stats request. The commit fixes the issue for all
APIs that use the indices stats API namely _cat/indices, _cat/shards and _stats.

closes #20298

primaryFound = true;
}
}
return primaryFound ? primaryStats : new CommonStats(CommonStatsFlags.ALL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the all flags? it seems arbitrary?

@bleskes
Copy link
Contributor

bleskes commented Sep 14, 2016

If I understand correctly the problem is that it may be the case that an index exists but it doesn't have any shard causing stats elements to be missing. I agree it would be nice to return empty stats objects rather than null, but I think we should honor the initial flags rather than blindly supply all stats.

also can we have tests?

@javanna
Copy link
Member

javanna commented Sep 14, 2016

I don't see anything specific to cat indices among these changes, I think they modify indices stats api, hence also cat indices that uses it. Can we update the title/description/labels of the PR to reflect what apis it changes?

@javanna
Copy link
Member

javanna commented Sep 14, 2016

One more thing: I wonder if this issue is specific to the tribe node, or can also happen with any node, or maybe just client nodes?

Currently, when an index exists in the cluster state but has no shards for reporting stats,
the missing stats object cause a `NullPointerException` when requesting the indices stats.
In this commit missing stats object for an index are initialized as empty stats instead
of null, honoring the stats flags set in the stats request. The commit fixes the issue for all
APIs that use the indices stats API namely `_cat/indices`, `_cat/shards` and `_stats`.

closes elastic#20298
@areek areek force-pushed the fix/handling_shard_stats branch from 96c8616 to 51d7010 Compare September 19, 2016 17:36
@areek areek changed the title Fix transient NPE while executing _cat/indices in tribe node Fix handling indices stats request when all shards are missing Sep 19, 2016
@areek areek added :Data Management/Stats Statistics tracking and retrieval APIs and removed :Data Management/CAT APIs Text APIs behind /_cat :Tribe Node labels Sep 19, 2016
@areek
Copy link
Contributor Author

areek commented Sep 19, 2016

If I understand correctly the problem is that it may be the case that an index exists but it doesn't have any shard causing stats elements to be missing. I agree it would be nice to return empty stats objects rather than null, but I think we should honor the initial flags rather than blindly supply all stats.

Thanks @bleskes for clarifying the problem statement, I was investigating this issue with tribe node, hence was too specific in my description. Now we honor the request stats flags instead of supplying all the stats by carrying over the request stats flag to the stats response.

also can we have tests?

Added this condition in RestIndicesActionTests, I wanted to add unit tests for this but it turned out to be non-trivial.

Can we update the title/description/labels of the PR to reflect what apis it changes?

Thanks @javanna for pointing it out, I updated these accordingly.

I wonder if this issue is specific to the tribe node, or can also happen with any node, or maybe just client nodes?

After some digging, this issue can happen on any node, when indices are removed/closed after the indices have been resolved for the stats request and before executing the stats request on the node.

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@dakrone
Copy link
Member

dakrone commented Apr 7, 2017

@areek is thing still being worked on?

@rjernst
Copy link
Member

rjernst commented Jun 9, 2017

I'm closing this PR since I do not think @areek is interested in bringing it up to date with master. If that is incorrect, please reopen.

@clintongormley
Copy link
Contributor

This is still a bug that needs to be fixed - I'll mark it as adoptme

@zcola
Copy link

zcola commented Aug 11, 2017

2.4.4 will still appear, we use "_cat / indices" as node health monitoring,Not only tribe node, but also data node will appear

@rjernst
Copy link
Member

rjernst commented Oct 10, 2017

@clintongormley I'm going to close this again, as we already have an issue to track this (#20298) and anyone who wants address this will still need to open a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Data Management/Stats Statistics tracking and retrieval APIs help wanted adoptme
Projects
None yet
Development

Successfully merging this pull request may close these issues.

java.lang.NullPointerException in Tribe node
8 participants