-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
Improve connection closing in RemoteClusterConnection
#22804
Conversation
Some tests verify that all connection have been closed but due to the async / concurrent nature of `RemoteClusterConnection` there are situations where we notify listeners that trigger tests to finish before we actually closed all connections. The race is very very small and has no impact on the code correctness. This commit documents and improves the way we close connections to ensure test won't fail with false positives. Closes elastic#22803
// we have to close this connection before we notify listeners - this is mainly needed for test correctness | ||
// since if we do it afterwards we might fail assertions that check if all high level connections are closed. | ||
// from a code correctness perspective we could also close it afterwards. This try/with block will | ||
// maintain the actual exceptions thrown from within the try block and suppress the ones that are possible thrown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly thrown?
@@ -370,6 +370,9 @@ void collectRemoteNodes(Iterator<DiscoveryNode> seedNodes, | |||
ClusterStateRequest request = new ClusterStateRequest(); | |||
request.clear(); | |||
request.nodes(true); | |||
// here we pass on the connection since we can only close it once the sendRequest returns otherwise | |||
// due to the async nature (it will return before it's actually send) this can cause the request to fail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's actually sent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// since if we do it afterwards we might fail assertions that check if all high level connections are closed. | ||
// from a code correctness perspective we could also close it afterwards. This try/with block will | ||
// maintain the actual exceptions thrown from within the try block and suppress the ones that are possible thrown | ||
// by closing hte connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/hte/the
Some tests verify that all connection have been closed but due to the async / concurrent nature of `RemoteClusterConnection` there are situations where we notify listeners that trigger tests to finish before we actually closed all connections. The race is very very small and has no impact on the code correctness. This commit documents and improves the way we close connections to ensure test won't fail with false positives. Closes #22803
* master: (47 commits) Remove non needed import use expectThrows instead of manually testing exception Fix checkstyle and a test Update after review Read ec2 discovery address from aws instance tags Invalidate cached query results if query timed out (elastic#22807) Add remaining generated painless API Generate reference links for painless API (elastic#22775) [TEST] Fix ElasticsearchExceptionTests Add parsing method for ElasticsearchException.generateThrowableXContent() (elastic#22783) Improve connection closing in `RemoteClusterConnection` (elastic#22804) Docs: Cluster allocation explain should be on one page Remove DFS_QUERY_AND_FETCH as a search type (elastic#22787) Add repository-url module and move URLRepository (elastic#22752) fix date-processor to a new default year for every new pipeline execution. (elastic#22601) Add tests for top_hits aggregation (elastic#22754) [TEST] Added this for 93a28b0 submitted via elastic#22772 Fix typo in comment in OsProbe.java Add new ruby search library to community clients doc (elastic#22765) RangeQuery WITHIN case now normalises query (elastic#22431) ...
Some tests verify that all connection have been closed but due to the
async / concurrent nature of
RemoteClusterConnection
there are situationswhere we notify listeners that trigger tests to finish before we actually
closed all connections. The race is very very small and has no impact on the
code correctness. This commit documents and improves the way we close
connections to ensure test won't fail with false positives.
Closes #22803