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
SearchContext is occasionally closed prematurely #5165
Comments
I looked at the gist and I think you should submit this as a PR! Good catch! Can you make sure you sign the CLA as well so we can pull this in quickly. One comment about the initialization I think we should initialize the new context with |
Will create a PR and sign the CLA shortly. Regarding initialization, I thought about using |
@jaymode I agree on the |
Fixes SearchContext from being closed during initialization or immediately after processing is started Closes elastic#5165
Fixes SearchContext from being closed during initialization or immediately after processing is started Closes #5165
Fixes SearchContext from being closed during initialization or immediately after processing is started Closes #5165
Fixes SearchContext from being closed during initialization or immediately after processing is started Closes #5165
Fixes SearchContext from being closed during initialization or immediately after processing is started Closes elastic#5165
Fixes SearchContext from being closed during initialization or immediately after processing is started Closes elastic#5165
We have noticed that sometime all shards do not respond to a DFS query then fetch and we get only 4/5 shards responding (and in debugging noticed the same for query then fetch). Turning the logs to debug we see the following message when only 4/5 shards respond.
Looking into what causes this, I was able to reproduce the issue more quickly by setting the SearchService reaper thread to run almost continuously by explicitly setting "search.keep_alive_interval" to a low value in the milliseconds range vs every minute. (we do see the same behavior without modifying this value, but
I saw two issues occur with some extra debugging. The first is that when SearchContext is created, the default value of lastAccessedTime is 0 and if the reaper runs against that context quickly enough, the context will be freed before it is used.
The second the reaper calls context.lastAccessTime() multiple times, but the value can change after the first if statement and an incorrect value will be used in the next statement (such as -1 when the context is being used).
This gist contains code that I have used to resolve the issues. If this needs to be submitted as a pull request, I can do that as well.
The text was updated successfully, but these errors were encountered: