-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[BUG] Parts of Rest High-Level Client not thread-safe #10065
Copy link
Copy link
Closed
Labels
ClientsClients within the Core repository such as High level Rest client and low level clientClients within the Core repository such as High level Rest client and low level clientbugSomething isn't workingSomething isn't workingv2.11.0Issues and PRs related to version 2.11.0Issues and PRs related to version 2.11.0v3.0.0Issues and PRs related to version 3.0.0Issues and PRs related to version 3.0.0
Metadata
Metadata
Assignees
Labels
ClientsClients within the Core repository such as High level Rest client and low level clientClients within the Core repository such as High level Rest client and low level clientbugSomething isn't workingSomething isn't workingv2.11.0Issues and PRs related to version 2.11.0Issues and PRs related to version 2.11.0v3.0.0Issues and PRs related to version 3.0.0Issues and PRs related to version 3.0.0
Describe the bug
We were working on an issue in Graylog today when we found out that it is a deadlock between two threads which are stuck in the OpenSearch Rest High-Level Client. The underlying issue is that we have two threads trying to perform (different!) requests to OpenSearch at the same time, which are implicitly making use of the
Settingsclass. This class is inherently unsafe in multi-threaded usage, due to its use of static variables/staticBuilderclass/the circular reference between the outer class and the static nested class.Our pragmatic fix was to make sure that both threads are started at different times, so initialization of the
Settingsclass through thread 1 should be done when thread 2 starts, mitigating the problem for us. This is the related PR explaining and working around the issue.It would be better though, if you would restructure the class to remove any of the factors causing a potential deadlock when it is used in two different threads simultaneous.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Plugins
Please list all plugins currently enabled.
Screenshots
If applicable, add screenshots to help explain your problem.
Host/Environment (please complete the following information):
Additional context
Add any other context about the problem here.