Skip to content

Fix flaky 04344_server_ast_fuzzer_insert_limit (filesystem cache lock wait) - #122567

Merged
tiandiwonder merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04344-table-off-fs-cache
Sep 29, 2026
Merged

tiandiwonder merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04344-table-off-fs-cache

Conversation

@groeneai

@groeneai groeneai commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #114077

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

04344_server_ast_fuzzer_insert_limit fails on Stateless tests (arm_asan_ubsan, azure, parallel) with Code: 159 ... Timeout exceeded: elapsed N ms, maximum: 20000.000 ms on a seed INSERT: 5 times in 90 days, all on that lane, twice since #114077 was closed (2026-09-27 job, 2026-09-17 job).

Root cause: on that lane MergeTree tables default to a write-through filesystem cache. Every file a part writes is added to the cache's priority queue under an exclusive lock, and debug and sanitizer builds randomly run a full cache consistency check (check_cache_probability) that holds the same lock shared while it stats every entry. The failing INSERTs spent 20,454 of 20,575 ms and 28,011 of 28,097 ms in FilesystemCachePriorityWriteLockMicroseconds, the 2026-09-27 writer thread was in LRUFileCachePriority::add in 21 of 21 profiler samples, and the parts' Azure uploads took 0.9-2.9 ms each. #114077 read this wait as Azure latency and raised the bound; it was closed after two quiet months.

Change: pin t_04344 to the local default storage policy. Where its parts live is incidental to what the test checks (stripping of seed SETTINGS), so no bound is widened. t_04344_storage keeps the lane default, since its SETTINGS clause is itself a carrier (its one small CREATE write has not failed in 90 days).

Validation, debug build with the CI configs and a write-through local_cache as the MergeTree default: at check_cache_probability = 1 with ~335k entries and 8 cached readers, the unmodified test failed 4 of 5 runs with the CI message and stack (~99% lock wait), the changed one passed 3 of 3, and at probability 0 the unmodified one passed 3 of 3. 50/50 randomized runs on the local default, 20/20 on the write-through default at the CI probability.

The check's cost on write-through caches is its owners' lever; #95946 lowered its probability once.


Workflow [PR]
Sync PR [sync-upstream/pr/122567]

Version info

  • Merged into: 26.10.1.954-master (included in 26.10 and later)

… 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]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet labels Sep 27, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding; full pass on this head).

# Sev Finding Verdict Evidence / action
1 ⚠️ The .reference does not assert that t_04344 lands on the default disk, so the test stays green with the pin removed unless the lock wait happens DISAGREE I measured the pin's effect with it removed: under cache-check load the unmodified test failed 4 of 5 runs with the CI error and stack, the pinned one passed 3 of 3; without load the two files separate every run on where the parts land and on cache-write bytes (3,724 vs 0); 20 randomized runs on a write-through default put all 630 t_04344 parts on default. A disk_name assertion stays green with the pin removed on every lane whose MergeTree default is already local, so it would only tie this fuzzer test's output to the storage config.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-8:20260927-184300

@clickhouse-gh

clickhouse-gh Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9758102]

Summary: ✅


AI Review

Summary

This PR pins t_04344 to storage_policy = 'default' so the seed INSERT and BACKUP path no longer goes through the write-through filesystem cache that was exhausting max_execution_time on the arm_asan_ubsan Azure lane. I did not find a correctness or coverage regression in the test: default is a built-in local storage policy in the test configurations, and the dedicated ASTStorage carrier coverage remains in t_04344_storage.

Final Verdict

Status: ✅ Approve

@tiandiwonder
tiandiwonder added this pull request to the merge queue Sep 29, 2026
Merged via the queue into ClickHouse:master with commit 5a91e0a Sep 29, 2026
149 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 29, 2026
JTCunning pushed a commit to JTCunning/ClickHouse that referenced this pull request Oct 21, 2026
On the azure lane the default MergeTree storage policy is a write-through
filesystem cache. The test's valid native-protocol INSERT writes a one-row
part, and every file of that part reserves cache space under the cache's
priority write lock. In Stateless tests (arm_asan_ubsan, azure, parallel) on
PR ClickHouse#126978 that INSERT spent 34.07 s of 34.43 s waiting on the lock
(FilesystemCachePriorityWriteLockMicroseconds), so the server's correct End of
stream arrived 4.4 s after the python client's hard-coded 30 s socket timeout
and the test failed with TimeoutError in readStrict.

The storage is incidental to a native-protocol LowCardinality test, so pin
the table to storage_policy = 'default' (the local disk on every lane). The
part write stays MergeTree, the 30 s hang guard and the .reference are
unchanged. Same shape as ClickHouse#122567 (04344) and ClickHouse#126252 (04949) for this lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-fuzzing Fuzzers: BuzzHouse (the query generator in the client), the AST fuzzer (QueryFuzzer), and the lib... and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-fuzzing Fuzzers: BuzzHouse (the query generator in the client), the AST fuzzer (QueryFuzzer), and the lib... groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants