Repository navigation
Fix flaky test 04344_server_ast_fuzzer_insert_limit - #109209
alexey-milovidov merged 1 commit into
Conversation
The test sets ast_fuzzer_any_query = 1, so the server-side AST fuzzer clones each CREATE ~30 times reusing the real table's UUID. Those clones contend the table's store/<uuid>/ directory, which slows the background drop worker. Under the CI test profile database_atomic_wait_for_drop_and_detach_synchronously is 1, so the trailing cleanup DROP TABLE waits in DatabaseCatalog::waitTableFinallyDropped for that background worker. That wait runs against the session max_execution_time = 20, and under the slowest sanitizer (msan + WasmEdge) it can exceed 20s and fail with Code: 159 TIMEOUT_EXCEEDED - a transient timeout on cleanup, not on anything the test verifies. Make the teardown DROPs asynchronous by pinning database_atomic_wait_for_drop_and_detach_synchronously = 0 before them. The fuzzed SELECT/INSERT queries still run under max_execution_time = 20 and the fuzz-context resource caps, so the test still proves the server-side AST fuzzer honors the insert/read limits; only the cleanup no longer blocks on the synchronous drop wait. Related: ClickHouse#108212 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260702-175800 |
|
cc @vdimir — could you review this test-only flaky fix? The server-side AST fuzzer clones each |
|
Workflow [PR], commit [0fc750e] Summary: ✅ AI ReviewSummaryThis PR makes the teardown in Final Verdict
|
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 145 line(s), 4 function(s) across 56 file(s) · Details Top files
|
CI finish ledger — 0fc750eTest-only PR (single
Session id: cron:our-pr-ci-monitor:20260702-230000 |
| -- its store/<uuid>/ directory. With the CI's synchronous atomic drop a teardown DROP then waits for | ||
| -- the background worker to clear that directory, and under the slowest sanitizer that wait can pass | ||
| -- max_execution_time and fail with TIMEOUT_EXCEEDED. Teardown does not need to wait synchronously. | ||
| SET database_atomic_wait_for_drop_and_detach_synchronously = 0; |
There was a problem hiding this comment.
But this can happen with any test, can't it? And if it were correct we see the issue more often in CI since it's a common pattern for all tests.
There was a problem hiding this comment.
No, a plain CREATE+DROP cannot hit this. Three things have to line up, and only the server-side AST fuzzer tests have all three:
max_execution_time = 20: a tight deadline this test sets to bound the fuzzer. A normal test leaves the default, so its teardown DROP has a far looser budget.ast_fuzzer_runs = 30+ast_fuzzer_any_query = 1: the fuzzer runs in a query finish callback and clones+executes ~30 fuzzed queries after each statement. Underany_query = 1those include the CREATE, whose AST is stamped in place with the table UUID (InterpreterCreateQuery:create.uuid = generateV4()), so the clones reuse it and contendstore/<uuid>/, starving the background atomic-drop worker for that UUID.- The CI profile forces
database_atomic_wait_for_drop_and_detach_synchronously = 1, so the trailing DROP waits inDatabaseCatalog::waitTableFinallyDropped, and that wait is charged against the 20s deadline (throwIfKilled->TIMEOUT_EXCEEDED).
Note the sync drop passes sync as ignore_delay to enqueueDroppedTableCleanup, so it is enqueued ahead of the 60s finalize delay and scheduled immediately. The >20s wait is therefore the background worker doing real work to clear store/<uuid>/, not the delay. For a generic test that worker finishes in milliseconds; here it is starved by the ~30 UUID-sharing fuzz clones. That is the specific difference.
Drop any one of the three and it does not fire, which is why it is rare (2 hits in 30 days, both on PR branches, 0 on master) rather than the universal failure a generic CREATE+DROP mechanism would produce. Only 7 of ~22,500 stateless tests set ast_fuzzer_runs at all, and just 2 executable ones set ast_fuzzer_any_query = 1.
Repro against a CI-like server (sync drop + 60s finalize delay), holding a UUID in the drop queue past a small max_execution_time: with sync=1 the DROP fails with Code 159 at the deadline; with sync=0 it returns in ~65ms.
The pin is teardown-only and does not change what the test verifies: the fuzzed SELECT/INSERT still run under max_execution_time = 20 plus the fuzzer's own resource caps, and the reference 4950/4950/4950/1 is unchanged. If you would rather keep the test untouched, the alternative is at the CI-profile/server level, but since only these fuzzer tests combine DDL fuzzing with the forced sync drop, the test-local pin is the least invasive correct fix.
alexey-milovidov
left a comment
There was a problem hiding this comment.
No problem, we can merge it. If this particular test appears to be bad, we can remove it.
7a44236
…t-fuzzer-sync-drop-timeout Fix flaky test 04344_server_ast_fuzzer_insert_limit
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Fixes a flaky
Code: 159 TIMEOUT_EXCEEDEDon the cleanupDROP TABLEof04344_server_ast_fuzzer_insert_limit, seen onStateless tests (amd_msan, WasmEdge, parallel, 2/2). 2 hits in 30 days (both on PR branches, 0 on master); reruns with the same randomized settings pass.CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107087&sha=f3fd77f2195993b30398ef6e21e9cb45cc99e27e&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20WasmEdge%2C%20parallel%2C%202%2F2%29
Root cause. The test sets
ast_fuzzer_any_query = 1, so the server-side AST fuzzer clones eachCREATE TABLEseed ~30 times, every clone reusing the real table's UUID and thus contending itsstore/<uuid>/data directory. This slows the background atomic-drop worker for that UUID. The CI test profile forcesdatabase_atomic_wait_for_drop_and_detach_synchronously = 1(tests/config/users.d/database_atomic_drop_detach_sync.xml) withdatabase_atomic_delay_before_drop_table_sec = 60, so the trailing cleanupDROP TABLEwaits inDatabaseCatalog::waitTableFinallyDroppedfor that worker. That wait is charged against the sessionSET max_execution_time = 20, and under the slowest sanitizer (msan + WasmEdge) it can exceed 20s and throwTIMEOUT_EXCEEDEDon the DROP. The timeout is on cleanup, not on anything the test verifies.Fix. Pin
database_atomic_wait_for_drop_and_detach_synchronously = 0before the teardown DROPs so they return without waiting for the background worker. The fuzzed SELECT/INSERT queries still run undermax_execution_time = 20and the fuzzer's own per-context resource caps, so the test still proves the server-side AST fuzzer honors the insert/read limits (reference output4950 / 4950 / 4950 / 1is unchanged).Validation. Reproduced the mechanism locally against a server configured like CI (sync drop + 60s finalize delay), holding a table in the drop queue past a small
max_execution_time:sync = 1): theDROPfails withCode: 159 TIMEOUT_EXCEEDEDat the deadline;sync = 0): theDROPreturns in ~65 ms.Full test run against the CI-like server: 15/15 passes, output matches the reference, no
TIMEOUT_EXCEEDEDon any teardown DROP.Version info
26.7.1.782(included in26.7and later)