Skip to content

Leave no stale readonly reader behind in tests 05104, 05227 and 05228 - #124342

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:groeneai/05104-pin-fuzzer-clones-of-table-disk-readers
Nov 6, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:groeneai/05104-pin-fuzzer-clones-of-table-disk-readers

Conversation

@groeneai

@groeneai groeneai commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

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):

Not required.

Description

Stress test (arm_release) on #118957 fails S3_ERROR No such key: reads of test_3.reader__fuzz_{2,3,4} get The specified key does not exist on data.packed of part all_1_6_1_16.

Those tables are clones of the test's readonly reader, made by the server-side AST fuzzer (ast_fuzzer_any_query = true in Stress). Each one attaches the writer's parts of that moment, and nothing drops it. The test's own DROP TABLE writer SYNC then deletes the objects (no hard-link refcount is involved), and later reads of the clones in the kept database (the fuzzer, 02046's merge(currentDatabase(), '') FINAL) fail. 05227 and 05228 have the same shape. In 05228 the reader DROP also runs after the writer's drop has finished, so an ignored one (ignore_drop_queries_probability = 0.2) leaves a stale reader too, and an ignored background writer DROP makes the test wait forever in SYSTEM WAIT FAILPOINT.

The change is test-only. The sessions that create the tables set ast_fuzzer_any_query = 0, and the sessions that drop them set ignore_drop_queries_probability = 0. Only the SELECTs of those sessions stay fuzzed; the ALTERs and OPTIMIZE of 05104 run in other sessions and stay fuzzed too. Stress retries a failed test in the same kept database, so the startup drops are pinned too, and each run gives its readonly disk a new name: a registered readonly disk keeps the listing it loaded, and a retry attached the earlier run's removed parts (Code: 499). If you prefer, the server-side fuzzer could instead drop the __fuzz_N clones of a dropped table, as the client fuzz loop does.

Validation

On a local server with the Stress fuzzer settings, one fixed database per run, as in Stress:

  • 05104: before, 816 fuzzed clone CREATEs in 87 runs, clones left in 13 databases, and merge(currentDatabase(), '') FINAL gives the CI error in 4. After: 0 fuzzed CREATEs in 80 runs, no table left.
  • 05228: before, reader clones survive and their read gives the CI error; after, 0 fuzzed CREATEs.
  • 05227: a clone survives only when the fuzzer drops the copied UUID clause (19 of 414 reader attempts in 05104 did); none of its 47 did in 10 runs, and after the change it makes no fuzzed CREATE in 10 runs.
  • In 05104 and 05228, removing any one pin brings back its clones or its leftover/hang (ignore_drop_queries_probability = 1).
  • Three runs of each test in one database: before (and with the pin alone), every rerun fails or hangs and the server logs 40, 4 and 8 The specified key does not exist lines; after, 3 of 3 pass with none. With an interrupted run's tables left over, the old startup block leaves the reader over removed objects in 9 of 50 runs; with the pin, none.

50 randomized runs of each test pass on a regular server; references are unchanged.


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

Version info

  • Merged into: 26.11.1.1479-master (included in 26.11 and later)

The Stress test runs the server-side AST fuzzer on every successful
statement, DDL included (`ast_fuzzer_runs = 5`, `ast_fuzzer_any_query = true`).
After `CREATE TABLE reader ... disk(readonly = true, ...)` it creates
`reader__fuzz_N`: more readonly tables over the same `table_disk` root, each
attached with the writer's parts of that moment, and nothing drops them.
The test's `DROP TABLE writer SYNC` then deletes the objects of those parts,
and later reads of the clones in the kept stress database (fuzzed reads,
02046's `merge(currentDatabase(), '') FINAL`) fail with
`S3_ERROR The specified key does not exist` on `data.packed`, which the
stress `No such key` check reports (PR ClickHouse#118957, Stress test (arm_release)).
05227 and 05228 build the same readonly reader over a writer they drop.

In 05228 the reader `DROP` also runs after the writer's drop has finished,
so a reader `DROP` ignored by `ignore_drop_queries_probability` (it becomes a
TRUNCATE of a read-only table and fails with TABLE_IS_PERMANENTLY_READ_ONLY)
leaves a stale reader as well, and an ignored background writer `DROP` makes
the test wait forever in `SYSTEM WAIT FAILPOINT ... PAUSE`. In 05104 and 05227
both drops share one multi-statement block, so an ignored reader `DROP` stops
the block before the writer drop; the pin there keeps the block's drops.

Pin `ast_fuzzer_any_query = 0` in the sessions that create the tables and
`ignore_drop_queries_probability = 0` in the sessions that drop them. Only
the SELECTs of those sessions stay fuzzed; the ALTERs and OPTIMIZE of 05104
run in other sessions and stay fuzzed too.

Measured locally with the Stress fuzzer settings and one fixed database per
run: 05104 left fuzzer clones in 13 of 87 databases before (816 fuzzed clone
CREATEs, the CI error reproduced by the 02046-style read in 4), none after
(0 fuzzed CREATEs in 80 runs); 05228 likewise. In 05227 a clone survives only
when the fuzzer drops the copied UUID clause (19 of 414 reader attempts in
05104 did); none of its 47 did in 10 runs, and after the change it makes no
fuzzed CREATE in 10 runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 7, 2026
@groeneai

groeneai commented Oct 7, 2026

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

Pre-publication review by an independent model (engine: codex; 3 findings in the first pass, 0 in the delta recheck after one fix round) plus my own review.

# Sev Finding Verdict Evidence / action
1 ❌ 05227 (and 05234) keep the same stale-reader path AGREE for 05227, fixed @ 46d0f8c 05227 pinned the same way; a clone there survives only when the fuzzer drops the copied UUID clause, so 0 of 47 in 10 runs was luck
1b ❌ same, for 05234 DISAGREE local object storage; the stress check matches only S3 Code: 499 ... The specified key does not exist (clickhouse_proc.py:1323)
2 ⚠️ no assertion that the reader and its clones were removed DISAGREE cannot fail in any run that compares output: regular CI has no server-side fuzzer and no ignored DROPs, Stress does not compare references
3 ⚠️ 05228's ALTER is no longer fuzzed, contrary to the description AGREE, fixed @ 46d0f8c the statement was wrong, not the pin: the description now says only the SELECTs of the pinned sessions stay fuzzed

Noted, not blocking: the server-side fuzzer can rewrite SYSTEM WAIT FAILPOINT ... PAUSE into a resume wait that blocks until the failpoint is disabled; that affects every test using it, so it is not changed here.

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

Session id: cron:clickhouse-review-slot-8:20261007-003100

@groeneai

groeneai commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. A readonly clone of the reader (the CI clone's DDL, no UUID), then DROP TABLE reader, DROP TABLE writer, then a read of the clone gives Code: 499 ... The specified key does not exist. With the Stress fuzzer settings: 816 fuzzed clone CREATEs in 87 runs before, 0 in 80 after.
b Root cause explained? Yes. The server-side AST fuzzer replays CREATE TABLE reader as reader__fuzz_N. Each clone attaches the writer's parts of that moment and is never dropped. The test's DROP TABLE writer SYNC deletes those objects, so a later read of a clone fails. In 05228 an ignored separate reader DROP leaves the same stale reader.
c Fix matches root cause? Yes. The table DDL sessions pin ast_fuzzer_any_query = 0 and the drop sessions pin ignore_drop_queries_probability = 0, so no table is left over the dropped root. Only the SELECTs of those sessions stay fuzzed; the ALTERs and OPTIMIZE of 05104 run in other sessions and stay fuzzed too. No tag, bound or data change.
d Test intent preserved / new tests added? Yes. Assertions and references are unchanged; 50/50 randomized runs of each test pass.
e Both directions demonstrated? Yes. Before: clones left in 13 of 87 databases (05104) and in 05228, and the 02046-style read gives the CI error. After: 0 clone CREATEs, 0 tables left (05227: 0 in 10 runs). In 05104 and 05228, removing any one pin brings back its clones, stale reader or hang.
f Fix is general across code paths? Yes. All S3 table_disk tests with a readonly reader over a writer root (05104, 05227, 05228) are pinned.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only setting pins).
h Backward compatible? (maintainer-approved exception only) N/A (test-only).
i Invariants and contracts preserved? Yes. When the test ends, no table remains whose parts point at objects of a dropped root. A run killed before its last block leaves the writer alive, so its reader is not stale.

Session id: cron:clickhouse-impl-slot-4:20261007-000100

@clickhouse-gh

clickhouse-gh Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f48651f]

Summary: ✅


AI Review

Summary

The three tests disable DDL fuzzing during table creation, prevent ignored cleanup drops, and use a fresh readonly disk for each run to avoid stale metadata on retries. No remaining findings. The two prior cleanup findings are withdrawn: DROP TABLE ... SYNC finishes removal before AST fuzzing, so a subsequent fuzzed UNDROP TABLE cannot restore the removed table.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Oct 7, 2026
clickhouse-test retries a failed test whose output has a retriable message
(`MESSAGES_TO_RETRY`, e.g. `(total) memory limit exceeded`), and a Stress
worker with a fixed `--database=test_<i>` runs the retry in the same database
without cleaning it, so the retry starts from what the earlier attempt left.

The startup `DROP TABLE IF EXISTS` statements still ran under the stress
`ignore_drop_queries_probability = 0.2`. When the writer `DROP` runs and the
`DROP` of a leftover readonly reader is ignored (it becomes a TRUNCATE and
fails with TABLE_IS_PERMANENTLY_READ_ONLY), the reader stays over the objects
the writer removed. Pin the setting there as well.

The retry also reused the readonly disk of the earlier attempt by name, and
that disk keeps the listing it loaded: the new reader attached the parts of
the earlier attempt, which are gone, and the server logged
`Code: 499 ... The specified key does not exist` for each of them. Give the
reader disk a new name in every run.

Measured on a local server. With the leftover writer and reader of an
interrupted run, the old startup block left the reader over removed objects
in 9 of 50 runs, and in none with the pin. Three runs of each test in one
database: before, every rerun failed (05227 hung) and the server logged 40, 4
and 8 such lines; with the pin alone the same; after, 3 of 3 pass with none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

This also fails on master, through a third reader of the clones: in Stress test (arm_msan), BACKUP DATABASE test_3 of 02915_lazy_loading_of_base_backups collects test_3.reader__fuzz_2, which the fuzzer cloned from this test's CREATE TABLE reader, and reads its data.packed 12 s after DROP TABLE writer SYNC removed it. The same check on another PR has the same shape (BACKUP DATABASE test_7 of 03001_backup_matview_after_modify_query, clones reader__fuzz_{0,2,4}). The ast_fuzzer_any_query = 0 pin on the reader session prevents those clones, so this PR covers both.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acceptable. I see no other way to avoid "no such key" with completely independent readers and writers.

@alexey-milovidov alexey-milovidov self-assigned this Nov 6, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 6, 2026
Merged via the queue into ClickHouse:master with commit 3c86dea Nov 6, 2026
178 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 Nov 6, 2026
@clickhouse-gh clickhouse-gh Bot added comp-object-storage-disks Object-storage disk layer: DiskObjectStorage, metadata storage adapters, transaction support for ... 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-object-storage-disks Object-storage disk layer: DiskObjectStorage, metadata storage adapters, transaction support for ... groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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