Repository navigation
Set exception if task cannot be scheduled in ThreadPoolCallbackRunnerLocal - #73629
Merged
Merged
Conversation
Contributor
|
This is an automated comment for commit 96d1b71 with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
davenger
commented
Dec 19, 2024
kssenii
approved these changes
Dec 19, 2024
21 tasks
This was referenced Jun 13, 2026
pull Bot
pushed a commit
to admariner/ClickHouse
that referenced
this pull request
Jun 28, 2026
…shutdown threadPoolCallbackRunnerUnsafe wrapped work in a std::packaged_task and scheduled it on a ThreadPool. When the pool is shut down (ThreadPool::finalize sets shutdown and the worker drains the queue with job_data.reset()), a still-queued task is destroyed without running. The bare packaged_task then destructs its std::promise with no stored value, so ~promise() stores a broken-promise std::future_error. std::future_error derives from std::logic_error, so when a waiter observes it via future.get() the server reports it through getCurrentExceptionMessageAndPattern, which calls abortOnFailedAssertion on any std::logic_error in debug/sanitizer builds, aborting the process during shutdown. Observed in CI as a Stress test / serverfuzz abort (STID 2508-38c6): a TaskTracker flush task scheduled through threadPoolCallbackRunnerUnsafe was dropped on shutdown, and the waiting merge task aborted with "The associated promise has been destructed prior to the associated state becoming ready". Replace the packaged_task with a small runnable that owns its std::promise and, when it is destroyed without having run, satisfies the promise with a normal DB::Exception (CANNOT_SCHEDULE_TASK) instead of leaving it broken. DB::Exception is not a std::logic_error, so the waiter now observes an ordinary, catchable error and the server no longer aborts. This mirrors the explicit-promise handling already used by the sibling ThreadPoolCallbackRunnerLocal (PR ClickHouse#73629) and preserves the existing ThreadGroupSwitcher-before-set ordering and the SCOPE_EXIT_SAFE callback release. Add a unit test that deterministically drops queued runner tasks on shutdown and asserts their futures never carry a broken-promise std::future_error. Co-Authored-By: Claude Opus 4.8 <[email protected]>
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
…shutdown threadPoolCallbackRunnerUnsafe wrapped work in a std::packaged_task and scheduled it on a ThreadPool. When the pool is shut down (ThreadPool::finalize sets shutdown and the worker drains the queue with job_data.reset()), a still-queued task is destroyed without running. The bare packaged_task then destructs its std::promise with no stored value, so ~promise() stores a broken-promise std::future_error. std::future_error derives from std::logic_error, so when a waiter observes it via future.get() the server reports it through getCurrentExceptionMessageAndPattern, which calls abortOnFailedAssertion on any std::logic_error in debug/sanitizer builds, aborting the process during shutdown. Observed in CI as a Stress test / serverfuzz abort (STID 2508-38c6): a TaskTracker flush task scheduled through threadPoolCallbackRunnerUnsafe was dropped on shutdown, and the waiting merge task aborted with "The associated promise has been destructed prior to the associated state becoming ready". Replace the packaged_task with a small runnable that owns its std::promise and, when it is destroyed without having run, satisfies the promise with a normal DB::Exception (CANNOT_SCHEDULE_TASK) instead of leaving it broken. DB::Exception is not a std::logic_error, so the waiter now observes an ordinary, catchable error and the server no longer aborts. This mirrors the explicit-promise handling already used by the sibling ThreadPoolCallbackRunnerLocal (PR ClickHouse#73629) and preserves the existing ThreadGroupSwitcher-before-set ordering and the SCOPE_EXIT_SAFE callback release. Add a unit test that deterministically drops queued runner tasks on shutdown and asserts their futures never carry a broken-promise std::future_error. Co-Authored-By: Claude Opus 4.8 <[email protected]>
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):
Fix for std::logical_error thrown when task cannot be scheduled.
Found in stress tests. Example stacktrace:
Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing):