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
Usage of NodeClient in BaseRestHandler of an ActionPlugin causes multi-node clusters to hang after version 7.9.0 #67960
Comments
If you run your cluster with assertions enabled, does your plugin throw an |
@DaveCTurner Yes, here are the details:
Thank you for your quick response! |
Adding to this: I enabled assertions for a pre-7.9 cluster, too, and the same assertion error was thrown. But without assertions enabled, the plugin worked as expected on that version of Elasticsearch. |
Ok that makes sense. Blocking calls in REST handlers, or transport threads more generally, aren't allowed as they have severe performance implications. That has been true for a very long time. The assertion that is tripping was added back in 1.5.0 (#9164) to warn you away from doing so. You should use the async API wherever possible, and fork to a different thread if async isn't possible for some reason. I believe the reason this changed in 7.9 was #46346; you ought to be able to demonstrate this by setting I'm not sure why the change in 7.9 wasn't mentioned in the release notes, I'll mark this as a doc bug to get that addressed. |
Pinging @elastic/es-docs (Team:Docs) |
Pinging @elastic/es-distributed (Team:Distributed) |
Thanks @DaveCTurner. I supposed the next question, then, is how to properly implement a REST handler that must wait for the results from one or more Elasticsearch requests before returning a response to the user. Should I field that question to discuss.elastic.co?
++ Good advice, I wasn't aware of the ability to enable assertions in Elasticsearch. |
Yes the forums.would be a better forum for that question. |
++ I've submitted my follow-up question to the discussion boards. Thank you for your help. |
In elastic#46346 we changed the distribution of work across event loops but this was marked as a `>non-issue` so did not get a mention in the release notes. However, plugin authors might need to be aware of this change, so this commit records it in the release notes as an enhancement instead. Closes elastic#67960
In #46346 we changed the distribution of work across event loops but this was marked as a `>non-issue` so did not get a mention in the release notes. However, plugin authors might need to be aware of this change, so this commit records it in the release notes as an enhancement instead. Closes #67960
In #46346 we changed the distribution of work across event loops but this was marked as a `>non-issue` so did not get a mention in the release notes. However, plugin authors might need to be aware of this change, so this commit records it in the release notes as an enhancement instead. Closes #67960
In #46346 we changed the distribution of work across event loops but this was marked as a `>non-issue` so did not get a mention in the release notes. However, plugin authors might need to be aware of this change, so this commit records it in the release notes as an enhancement instead. Closes #67960
In #46346 we changed the distribution of work across event loops but this was marked as a `>non-issue` so did not get a mention in the release notes. However, plugin authors might need to be aware of this change, so this commit records it in the release notes as an enhancement instead. Closes #67960
Closed by #68073. |
Elasticsearch version: >= 7.9.0
Plugins installed: Any custom
ActionPlugin
that uses theNodeClient
client from aBaseRestHandler
.JVM version: JDK 11
OS version: The test scripts (see below) used Docker CE 19.03.13 and docker-compose 1.27.4 on macOS 10.15.7
Description of the problem
When using a multi-node cluster, requests made by the
NodeClient
client from aBaseRestHandler
in anActionPlugin
will cause Elasticsearch to hang.Take this simple example (see entire sample plugin):
In this example, a simple search performed by the plugin's
NodeClient
will cause Elastisearch >= 7.9.0 to hang if that cluster has multiple nodes.Any action, whether it's creating an index or performing a search, from a custom plugin appears to cause multi-node cluster to hang.
I've labeled this as a "bug" because the usage of the
NodeClient
in plugins has worked since at least Elasticsearch 5.x, and the expected behavior stopped working after 7.9.0 without an explanation in the release notes.Steps to reproduce
I've provided a test script to simplify the reproduction of this issue.
Step 1. Download and extract my test script (elasticsearch-plugin-troubleshooting.zip) which contains:
./post-7.9/docker-compose.yml
- A 3-node Elasticsearch cluster at version 7.10.2 with a sample plugin installed./pre-7.9/docker-compose.yml
- A 3-node Elasticsearch cluster at version 7.8.1 with a sample plugin installed./test.sh
- A script to test plugin behavior in the two versions of ElasticsearchStep 2. Test the behavior of the plugin on Elasticsearch 7.8.1. Open two terminals:
cd pre-7.9
docker-compose up
./test.sh
Step 3. Observe the output. Notice that
./test.sh
performs three successful tasks:sample-index
) usingcurl
50 times.sample-index
) using the custom plugin endpoint (/_sample/create
) 50 times._sample/search
) 50 times.Step 4. Test the behavior of the plugin on Elasticsearch 7.10.2. Open two terminals:
cd post-7.9
docker-compose up
./test.sh
Step 5. Observe the output. Notice that
./test.sh
performs hangs when the custom plugin is used, unlike Step 3:sample-index
) usingcurl
50 times./_sample/create
) attempts to create an index (sample-index
).The text was updated successfully, but these errors were encountered: