Repository navigation
Make waiting for mutations interruptible: Fix hung waitForMutation not respecting query cancellation - #96756
Merged
Conversation
`StorageMergeTree::waitForMutation` used `condition_variable::wait` which blocks indefinitely without checking query cancellation. When a `DELETE` query is cancelled during stress tests, the wait never returns because the check lambda only looks at `shutdown_called` and mutation status, not at the query's cancellation state. This caused hung check failures in stress tests where `DELETE FROM system.session_log` queries from tests 02833 and 02834 would hang for 1200+ seconds after being cancelled. The fix replaces the indefinite `wait` with a `wait_for` loop that periodically calls `checkTimeLimit` on the process list element, which throws an exception if the query was cancelled. https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=eceab6911fb6b088b2a2cfa74afd0c139e700624&name_0=MasterCI&name_1=Stress%20test%20%28amd_debug%29 https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=3c501a28a835615f110df7d21b07c7cc9a670422&name_0=MasterCI&name_1=Stress%20test%20%28amd_debug%29 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
|
Workflow [PR], commit [908a8a8] Summary: ❌
|
Member
Author
|
It's hard to write a targeted test for this improvement, but our stress tests provide some sporadic coverage. |
Algunenano
approved these changes
Feb 12, 2026
Algunenano
left a comment
Member
There was a problem hiding this comment.
Looks good to me. There are a few other cases (at least 65 just in public) of std::condition_variable::wait, but in a superficial review I don't see anything too suspicious
Since `waitForMutation` now respects `max_execution_time`, the ALTER TABLE query with `mutations_sync = 2` may be cancelled with `TIMEOUT_EXCEEDED` before the mutation itself fails with OOM. Both outcomes are valid — the test verifies the server does not crash (issue #55279). Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add `DROP TABLE IF EXISTS` before creating and after using the table, so the test can be run multiple times in targeted/flaky CI modes without failing with "Table already exists". Co-Authored-By: Claude Opus 4.6 <[email protected]>
…kHouse into fix-hung-waitForMutation
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.
Summary
StorageMergeTree::waitForMutationusedcondition_variable::waitwhich blocks indefinitely without checking query cancellationDELETEquery is cancelled during stress tests, the wait never returns because the check lambda only looks atshutdown_calledand mutation statusDELETE FROM system.session_logqueries from tests02833_concurrent_sessionsand02834_remote_session_loghung for 1200+ secondswaitwith await_forloop that periodically callscheckTimeLimitto detect query cancellationCI reports:
Test plan
DELETE FROM system.session_logChangelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Synchronous waiting for mutations will respect query cancellation and time limits.
🤖 Generated with Claude Code
Version info
26.2.1.690