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 crash when Pool::Entry::disconnect() is called #50334
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Many Pool::Entry objects can keep the same pointer to Pool::Connection. If Pool::Entry::disconnect() is called on one such object, Pool::removeConnection() is called to remove Pool::Connection from the pool, where connection->ref_count is cleared and connection->removed_from_pool is set. Next Pool::Entry::~Entry() calls decrementRefCount() with 1. const auto ref_count = data->ref_count.fetch_sub(1); where data->ref_count will be negative, since it was cleared 2. checks removed_from_pool and deletes Pool::Connection but there might be multiple Entry objects still keep pointer to this Pool::Connection Suggesting not to clear ref_count on disconnect() and delete Pool::Connection only on the last Pool::Entry is being destroyed. Fixes ea375ef
robot-ch-test-poll2
added
the
pr-bugfix
Pull request with bugfix, not backported by default
label
May 30, 2023
This is an automated comment for commit ecea1ac with description of existing statuses. It's updated for the latest CI running
|
kssenii
added
the
can be tested
Allows running workflows for external contributors
label
May 30, 2023
kssenii
approved these changes
May 31, 2023
kssenii
added
the
pr-must-backport
Pull request should be backported intentionally. Use this label with great care!
label
Jun 15, 2023
This was referenced Jun 15, 2023
robot-clickhouse
added a commit
that referenced
this pull request
Jun 15, 2023
robot-clickhouse
added a commit
that referenced
this pull request
Jun 15, 2023
robot-clickhouse-ci-2
added
the
pr-backports-created
Backport PRs are successfully created, it won't be processed by CI script anymore
label
Jun 15, 2023
alexey-milovidov
added a commit
that referenced
this pull request
Jun 16, 2023
Backport #50334 to 23.3: Fix crash when Pool::Entry::disconnect() is called
alexey-milovidov
added a commit
that referenced
this pull request
Jun 16, 2023
Backport #50334 to 23.4: Fix crash when Pool::Entry::disconnect() is called
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
can be tested
Allows running workflows for external contributors
pr-backports-created
Backport PRs are successfully created, it won't be processed by CI script anymore
pr-bugfix
Pull request with bugfix, not backported by default
pr-must-backport
Pull request should be backported intentionally. Use this label with great care!
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Many Pool::Entry objects can keep the same pointer to Pool::Connection. If Pool::Entry::disconnect() is called on one such object, Pool::removeConnection() is called to remove Pool::Connection from the pool, where connection->ref_count is cleared and connection->removed_from_pool is set.
Next Pool::Entry::~Entry() calls decrementRefCount() with
Suggesting not to clear ref_count on disconnect()
and delete Pool::Connection only on the last Pool::Entry is being destroyed.
Fixes ea375ef
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):