{{ message }}
Fix possible 'associated promise has been destructed' in TestKeeper#73570
Merged
Conversation
Member
yariks5s
approved these changes
Dec 19, 2024
0dce045 to
07f7d94
Compare
Member
Author
|
I’ve made some updates to the patch since review, instead of skipping the check for |
d9f0745 to
704be53
Compare
Member
Author
pull Bot
pushed a commit
to AKJUS/ClickHouse
that referenced
this pull request
Jun 25, 2026
In Coordination::ZooKeeper::sendThread, after a request is popped from the queue the local RequestInfo is the sole owner of its callback until the request is inserted into operations (from which receiveEvent()/finalize() later satisfy it). Async callers such as ZooKeeper::asyncTryExistsNoThrow capture a shared_ptr<std::promise<...>> in that callback and hand the std::future to a waiting caller before the request is processed. If anything in the pop->insert window throws (the OpenTelemetry span finalize, addRootPath, or the operations map insert, all of which can allocate and throw under memory pressure), the local RequestInfo is destroyed while unwinding and the callback never runs. The captured std::promise is then destroyed unsatisfied, so the waiter's future.get() observes a std::future_error (broken promise). That future_error is a std::logic_error, which the server reports as a LOGICAL_ERROR and aborts on (see PR ClickHouse#51907). This matches the reported crash (STID 2508-34fb, ZooKeeper-client variant): ~promise<ExistsResponse> running from sendThread's teardown. Arm a SCOPE_EXIT guard over that window: if the request is dropped before its callback ownership transfers to operations, satisfy the callback with an error response (ZCONNECTIONLOSS if it was probably sent, otherwise ZSESSIONEXPIRED) instead of abandoning the promise. This mirrors how finalize() drains outstanding operations and the already-merged sibling fixes for the same error class (TestKeeper, PR ClickHouse#73570; the thread-pool callback runner, PR ClickHouse#107383). The fix is at the send layer, so it covers every async request type uniformly. Add a unit test reproducing the window contract: without the guard the future carries a broken-promise future_error; with the guard it carries a normal ZSESSIONEXPIRED response and nothing aborts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
...