Repository navigation
Conversation
The test intermittently failed with Code: 159. DB::Exception: Timeout exceeded: elapsed 25514.95756 ms, maximum: 20000 ms. (TIMEOUT_EXCEEDED) charged to one of its two INSERTs (8 failures / 176,696 OK in 90 days on PR refs, 0 on master; reruns pass 15/15). The session `SET max_execution_time = 20` at the top of the test is sized for the fuzzer's work, but on the two MergeTree INSERTs it also bounds object-store write latency the test does not control. In the server log of a failing `arm_asan_ubsan, azure` run (query_id 523bd414-7918) the worker thread emits only four lines in the gap: reserve 1 MiB, FakeDiskTransaction on disk cached_azure, then WriteBufferFromAzureBlobStorage: Committed single block 22.79 s later for a 100-row block, after which the statement throws at 25.5 s. The same shape was reproduced on a second azure failure at +28.3 s. The stall is host-wide rather than specific to this test: 27 unrelated queries exceeded 20 s in the same run (max 89.84 s across the two logs). They do not fail because they do not deadline themselves. The bound cannot simply be removed. On success each fuzzable statement runs 30 fuzzed clones inside the outer query's clock and the outer deadline is that loop's only aggregate bound: per-clone limits (max_execution_time = 10 at executeQuery.cpp:2338, a 30 s wall clock at :2404) bound each clone but not the loop, which is stopped only by checkTimeLimitSoft against the outer QueryStatus at :2235. Removing it would admit 30 x 30 s against the 600 s harness timeout. So raise it to 120 s on exactly the two INSERTs the logs implicate, using their existing SETTINGS clauses, and leave the session value at 20 s. The override lands because applySettingsFromQuery handles ASTInsertQuery's settings_ast (InterpreterSetQuery.cpp:218-223) at executeQuery.cpp:1578, before ProcessList::insert at :1623. Fuzzed clones do not inherit it: max_execution_time is in stripFuzzerSafetyLimitSettings (:1098-1108), so a clone keeps the fuzz-context cap of 10 s, which is the property this test exists to prove. 120 s clears the worst single-statement stall measured on these hosts (89.84 s) with headroom, stays about 37x above the measured 30-clone loop span (1.9-3.2 s), and is below the client receive_timeout (300 s) and the harness per-test timeout (600 s), so a genuine runaway still fails as a diagnosable Code: 159 rather than a harness kill. Raising the session value instead was rejected: two of the three seed SELECTs already run unbounded (max_execution_time = 0 means unlimited, and the `= DEFAULT` form resets to 0 after the changes are applied), so a session raise would weaken the fuzzer budget only on the statements that never fail. Verified from the effective values in system.query_log: the two INSERTs report 120 where the unmodified statement reports 20, every internal fuzzed query reports 10, and the fuzzer still produces 129 INSERT clones for this test. Test green, 50 runs with settings randomization enabled green, .reference unchanged.
The per-statement max_execution_time on the two INSERTs was 120, which the Stress harness forbids: tests/docker_scripts/stress_tests.lib installs a default-profile constraint of max 60 for this setting, and an INSERT's own SETTINGS clause is checked with THROW_ON_VIOLATION, so both statements would have thrown SETTING_CONSTRAINT_VIOLATION before executing. The stress harness does not assert on worker return codes, so the test would have silently stopped exercising both INSERT paths on that job. 60 is the largest value valid everywhere: SettingsConstraints only throws when max < value, so value == max is accepted. It is still 2.1x to 2.4x the observed failing costs (24.97 / 25.51 / 28.39 s) and ~19x the 30-clone fuzz loop's own span, so the aggregate fuzzer budget the bound provides is intact. Verified with the constraint installed locally: the 120 form is rejected with Code 452 before inserting any row, the 60 form runs, and the whole test passes and matches its reference. The fuzzer still produces 60 INSERT clones and every clone still runs at the fuzz-context cap of 10. Co-Authored-By: Claude Fable 5 <[email protected]>
Internal second-model reviewAn independent model reviewed this change cold against the description; I adjudicated each finding at
On the second: the necessary step, that the two I also corrected my own text before publishing: the Stress check is the only job installing that |
ValidationThe CI trigger is a >20 s object-store write, which is not reachable locally by luck, so the equivalent Four arms that move independently: no per-statement entry, fails; Generality: of the 14 files under |
|
cc @PedroTadim, could you review this? It is a test-only change: the two MergeTree |
|
Workflow [PR], commit [9f00fca] Summary: ❌
AI ReviewSummaryThis PR raises Final Verdict✅ No new findings. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units6 translation units recompiled, 3 s compile time in total, 6 of them have a recent master baseline. |
CI finish ledger - 9f00fcaEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Attribution is from the stack, not the STID prefix: This PR's whole diff is Session id: cron:our-pr-ci-monitor:20260810-023000 |
| -- Both INSERTs raise max_execution_time: it bounds their whole 30-clone fuzz loop and must exceed | ||
| -- the host's object-store write latency. 60 is the ceiling: the stress profile constrains it to 60. |
There was a problem hiding this comment.
checked the ceiling claim: stress_tests.lib sets a max_execution_time constraint with <max>60</max>, which is inclusive, so 60 is accepted and 61+ would be rejected before the statement runs. 60 is the largest legal value here.
| -- the host's object-store write latency. 60 is the ceiling: the stress profile constrains it to 60. | ||
| INSERT INTO t_04344 SELECT number, toString(number), range(number % 8) FROM numbers(100) | ||
| SETTINGS max_rows_to_read = 0, read_overflow_mode = 'throw'; | ||
| SETTINGS max_rows_to_read = 0, read_overflow_mode = 'throw', max_execution_time = 60; |
There was a problem hiding this comment.
this doesn't weaken the runaway-fuzz property: fuzzed clones are still pinned to max_execution_time = 10 on the fuzz context, and the seed's max_execution_time is stripped from every clone in stripFuzzerSafetyLimitSettings, so raising the seed to 60 can't leak in.
| -- overrides, so this stays bounded even though the seed asks for a 1M-row block. | ||
| INSERT INTO t_04344 SELECT number, toString(number), range(number % 8) FROM numbers(100) | ||
| SETTINGS min_insert_block_size_rows = 1000000, max_block_size = 1000000, max_rows_to_read = 0; | ||
| SETTINGS min_insert_block_size_rows = 1000000, max_block_size = 1000000, max_rows_to_read = 0, max_execution_time = 60; |
There was a problem hiding this comment.
the 60 s covers the real object-store write (~22-28 s observed) plus the 30-clone loop, which is bounded by this same outer deadline via checkTimeLimitSoft.
|
Dear @tiandiwonder, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
The test is no longer flaky |
… lock wait) On the `Stateless tests (arm_asan_ubsan, azure, parallel)` lane MergeTree tables default to the `azure_cache` policy, whose disk `cached_azure` is a write-through filesystem cache (cache_on_write_operations = 1). Every file a part writes is registered in the cache priority queue by LRUFileCachePriority::add, which takes the queue lock exclusively. Debug and sanitizer builds run FileCache::assertCacheCorrectness from FileCache::getOrSet/get with probability check_cache_probability (0.001), and its second pass walks the whole queue under that lock shared, checking the file of every entry on disk. With ~42k entries on that IO-saturated host a pass takes ~2.3 s (1,086 passes, 2,517 s of checking and 7,673 s of priority write-lock wait server-wide in one job), so each of the ~11 files of a 100-row part can wait seconds. The test bounds its seed statements with the session max_execution_time = 20, and the seed INSERTs failed with Code 159: - 2026-09-27, PR ClickHouse#122520: block-forming INSERT, elapsed 20,575 ms, of which 20,454 ms was FilesystemCachePriorityWriteLockMicroseconds - 2026-09-17, PR ClickHouse#104076: plain INSERT, elapsed 28,097 ms, 28,011 ms waiting The trace_log of the 2026-09-27 query shows its writer thread in SharedMutex::lock <- LRUFileCachePriority::add <- FileCache::doTryReserve <- FileSegment::reserve <- CachedOnDiskWriteBufferFromFile::cacheData in 21 of 21 samples, and the part's 11 blob uploads took 1.6-2.9 ms each, so the time is the cache lock, not object storage latency. In the same jobs, parts on the local `default` disk took at most 104 ms / 54 ms, versus 20.6 s / 33.5 s on cached_azure. Pin t_04344 to the implicit local `default` storage policy. Where its parts live is incidental to what the test verifies (stripping of seed SETTINGS on the INSERT, block-forming, CREATE storage and BACKUP carriers), so its INSERTs, their fuzzed clones, the BACKUP and the teardown DROP no longer touch the cache, and no time bound is widened: the session max_execution_time = 20 still bounds the fuzz loop. t_04344_storage keeps the lane's default policy, because its SETTINGS clause must hold only max_rows_to_read for the empty-SETTINGS pruning carrier. Reproduced locally on a debug build with the CI test configs, the write-through local_cache as the MergeTree default, check_cache_probability = 1, ~335k cache entries and 8 concurrent readers of a cached table: the unmodified test failed 4 of 5 runs with Code 159 on a seed INSERT (elapsed 31.8-50.4 s, 98.9-99.3% of it priority write-lock wait, same stack as CI). With this change it passed 3 of 3 under the same load, while 8 of 9 seed-shaped INSERTs into a cached table in the same windows waited 24-47 s. With check_cache_probability = 0 and the same cache and readers, the unmodified test passed 3 of 3 with seed INSERT lock waits under 0.4 s. ClickHouse#114077 raised the INSERTs' bound instead, reading this wait as Azure latency; it was closed after two quiet months and the test failed twice since. Related: ClickHouse#114077 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #109209 (fixed the teardown-DROP facet of the same test)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
04344_server_ast_fuzzer_insert_limitintermittently fails withCode: 159 ... elapsed 25514.95756 ms, maximum: 20000 ms (TIMEOUT_EXCEEDED)charged to one of its twoINSERTs: 3 times in 90 days, all onStateless tests (arm_asan_ubsan, azure, parallel), against 163,155OK on PR refs and 0 / 14,497 OK on master and release. Its 5 other failures there (
DROP/seedCode: 159,see #109209; host OOM) are out of scope.
Root cause: the session
SET max_execution_time = 20is sized for the fuzzer's work, but on the twoMergeTree
INSERTs it also bounds object-store write latency the test does not control. In a failingarm_asan_ubsan, azurerun the worker thread logsWriteBufferFromAzureBlobStorage: Committed single block22.79 s after reserving space for a 100-row block; a second repeats it at +28.3 s. 27 unrelated queries
also exceeded 20 s there, so the stall is host-wide.
It cannot just be removed: each fuzzable statement runs 30 fuzzed clones inside the outer query's clock,
and that deadline is the loop's only aggregate bound. So it is raised to 60 s on the two implicated
INSERTs, via their existingSETTINGSclauses. The session value stays 20 s and clones keep thefuzz-context cap of 10 s (
max_execution_timeis stripped from fuzzed queries), the property under test.60 s and not more: the Stress harness constrains
max_execution_timeto max 60(
tests/docker_scripts/stress_tests.lib) and a per-statement clause is checked withTHROW_ON_VIOLATION,so a larger value would be rejected before the statement runs, silently dropping this coverage. That is over
2x the failing costs (24.97 / 25.51 / 28.39 s).
Verified from
system.query_log: the twoINSERTs report an effective 60 where the unmodified statementreports 20, and every clone still reports 10. With that constraint installed locally, 60 runs while a larger
value is rejected before a row is inserted. 50/50 randomized runs pass.