Skip to content

Throw a clear error when a marks file listed in checksums is missing on disk - #107150

Open
groeneai wants to merge 20 commits into
ClickHouse:masterfrom
groeneai:groeneai/improve-missing-marks-file-error
Open

groeneai wants to merge 20 commits into
ClickHouse:masterfrom
groeneai:groeneai/improve-missing-marks-file-error

Conversation

@groeneai

@groeneai groeneai commented Jun 11, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Improvement

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

Improved the error message when a marks file that is listed in a data part's checksums is missing on disk. Reading such a column, or loading the part's index granularity, now raises NO_FILE_IN_DATA_PART naming the part, the missing file and the part's on-disk state, instead of an opaque std::filesystem file_size: No such file or directory error.

Description

MergeTreeMarksLoader::loadMarksImpl derives the marks file path from the part's own checksums (getStreamNameForColumn only returns a stream name listed there), so the file is expected to exist. When it does not, the read fails with Code: 1001 ... std::filesystem::filesystem_error: in file_size: No such file or directory, which names neither the affected part nor its on-disk state.

This surfaces in the flaky integration test test_rename_column::test_rename_distributed_parallel_insert_and_select (Integration tests, amd_tsan; report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100703&sha=e93ea3312f0d1107b3977560deafaa4241bd89b7&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%201%2F6%29 ) under concurrent RENAME COLUMN + INSERT + SELECT. CIDB showed it on 3 unrelated PRs over 30 days and never on master: a rare concurrency window, not one PR's regression.

This PR does not fix that race, which does not reproduce locally (94/94 idle and CPU-jittered iterations passed). It makes the next occurrence diagnosable: the marks read is wrapped in try/catch and, when the marks file turns out to be genuinely absent, the failure is rethrown as NO_FILE_IN_DATA_PART. The check runs on the error path only, so a successful load pays nothing. The index-granularity load path gets the same treatment, for wide and for compact parts.

Code: 226. DB::Exception: Marks file 'b.cmrk2' does not exist on disk in part 'all_1_1_0' at
'.../all_1_1_0/'. The file is listed in the part's checksums. Part columns: [...].
Checksums files: [a.bin, a.cmrk2, ...]. Files on disk: [a.bin, a.cmrk2, ...]. (NO_FILE_IN_DATA_PART)

tests/integration/test_missing_marks_file covers one case per call site: the query read path, and the index-granularity load path for wide and for compact parts. It is an integration test because it deletes a marks file from a live part, which stateless tests may not do. Verified in both directions: with only the four production files reverted to master, all three cases fail, the read path on the Code: 1001 message and both load paths on the diagnostic being absent from system.text_log.


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

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes, for the new error path: create a wide-part MergeTree table, rm one column's .cmrk2 from the active part dir, SYSTEM DROP MARK CACHE, then SELECT that column. It throws Code 226 NO_FILE_IN_DATA_PART every time (test 03810_missing_marks_file_error). The underlying race in test_rename_distributed_parallel_insert_and_select is NOT deterministically reproducible on a single host (94/94 idle and CPU-jittered iterations passed); it needs CI's heavy concurrent lanes. This PR is scoped to the diagnostic, not the race fix, so the relevant repro is the one above.
b Root cause explained? For the diagnostic: loadMarksImpl derives mrk_path from the part's own checksums (getStreamNameForColumn only returns a stream present in checksums.files), then calls getFileSize(mrk_path). If the file is absent on disk, std::filesystem::file_size throws a bare filesystem_error (Code 1001) carrying only the path, no part/checksums/disk context, which is undiagnosable in CI. For the race itself: the cmrk2 fs-error requires a part whose in-memory checksums list <col>.cmrk2 while the physical file is gone, a checksums-vs-disk divergence that only manifests under heavy concurrent RENAME+INSERT+SELECT. This PR does not claim to fix that; it makes the next hit diagnosable.
c Fix matches root cause? Yes for the diagnostic goal: replace the opaque filesystem_error with a typed NO_FILE_IN_DATA_PART that dumps the exact discriminating state (part name, path, columns, checksums-listed files, on-disk listing). This is precisely the information needed to determine, on the next CI occurrence, whether the divergence is a stale reader, a swapped part, or a cleanup race.
d Test intent preserved / new tests added? New stateless test 03810_missing_marks_file_error added; it removes a marks file and asserts the typed error. No existing test asserted the old opaque text (verified). No behavior change to successful reads.
e Both directions demonstrated? Yes. Without the change, the deleted-marks scenario produces Code 1001 std::filesystem_error: in file_size: No such file [b.cmrk2] (the exact CI symptom). With the change, it produces Code 226 NO_FILE_IN_DATA_PART: Marks file 'b.cmrk2' does not exist in part 'all_1_1_0' ... Checksums files: [..., b.cmrk2, ...]. Files on disk: [...]. Reading an intact column still returns correct results.
f Fix is general, not a narrow patch? The check sits at the single chokepoint where any part's marks file is loaded (MergeTreeMarksLoader::loadMarksImpl), so it covers every column/part/storage that goes through marks loading, not just the rename case. It runs only on the error path (after existsFile returns false), so there is no hot-path cost. It is intentionally a diagnostic, not a behavioral guard that would mask the upstream race; the underlying race remains tracked for a separate root-cause fix once it can be reproduced.

Session id: cron:clickhouse-worker-slot-0:20260611-044100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @CurtizJ @alesapin — could you review this? It replaces the opaque std::filesystem_error: in file_size: No such file [<col>.cmrk2] (Code 1001) thrown by MergeTreeMarksLoader when a marks file listed in a part's checksums is missing on disk, with a typed NO_FILE_IN_DATA_PART error that dumps the part name, columns, checksums-listed files, and the actual on-disk listing. Error-path only, no hot-path cost. Motivated by the flaky test_rename_distributed_parallel_insert_and_select cmrk2 failure, which is currently undiagnosable from the message alone.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Jun 11, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6ac8ede]

Summary: ❌

job_name test_name status info comment
AST fuzzer (amd_debug, targeted) FAIL
Server unresponsive: memory limit exceeded FAIL cidb

AI Review

Summary

This PR replaces the opaque missing-marks-file error with NO_FILE_IN_DATA_PART and moves the regression coverage to tests/integration. The local eager-read paths are improved, but the conversion still misses deferred read carriers, so the PR does not yet deliver the advertised diagnostic consistently across supported MergeTree read paths.

Findings

⚠️ Majors

  • [src/Storages/MergeTree/MergeTreeMarksLoader.cpp:205-217,255-298] loadMarksImpl only converts exceptions from getFileSize and readFile; the actual marks decode (reader->readStrict / readBinaryLittleEndian) runs after those try blocks. With use_reader_executor = 1, readFile can return a lazy PipelineReadBuffer, so a file that exists for sizing/build but disappears before the first deferred open still surfaces the lower-level file-read exception instead of NO_FILE_IN_DATA_PART.
    Suggested fix: keep the decode loop under the same conversion, or otherwise disable the deferred executor path for marks files until the conversion runs on the actual read failure.
  • [src/Storages/MergeTree/MergeTreeMarksLoader.cpp:401-439] throwIfMarksFileMissing treats existsFile as the source of truth, but on metadata-backed object-storage parts existsFile and getFileSize only consult metadata, not the underlying blob store. If the marks blob is gone while metadata still lists it, the wide/compact loadIndexGranularity catch blocks rethrow the raw remote-storage error instead of the new diagnostic, so the PR's user-facing contract still fails on object storage.
    Suggested fix: convert the failure at the actual blob read site, or teach the helper to verify the underlying blob/object rather than only metadata before deciding the marks file still "exists".
Tests
  • ⚠️ The new integration suite proves only the eager local-disk carriers. Add one object-storage test that removes the remote marks blob while metadata/checksums survive and asserts NO_FILE_IN_DATA_PART, and one failpoint or injected-reader test for use_reader_executor = 1 that deletes the local marks file after sizing/build but before the first readStrict.
Final Verdict

Changes requested. The current patch is an improvement for eager local-disk reads, but it still leaves supported deferred-read carriers on the old opaque exception path.

LLVM Coverage Report

Measured on commit 6ac8ede.

Metric Baseline Current Δ
Lines 88.80% 88.80% +0.00%
Functions 91.70% 91.70% +0.00%
Branches 81.10% 81.10% +0.00%

Changed lines: Changed C/C++ lines covered: 69/78 (88.46%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 11, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (updated for 91c0bc2)

# Question Answer
a Deterministic repro? Yes. 03810_missing_marks_file_error deterministically removes a wide part column stream marks file (b.cmrk2), drops the mark cache, and reads the column. Manually verified the typed error fires every run.
b Root cause explained? This PR is a diagnostic improvement, not a race fix. The marks file is referenced by the part checksums but missing on disk (surfaced by a concurrent RENAME COLUMN + INSERT + SELECT race in test_rename_distributed_parallel_insert_and_select); previously this produced an opaque std::filesystem_error from file_size.
c Fix matches root cause? Yes. The typed NO_FILE_IN_DATA_PART is now raised from the catch path of the real getFileSize/readFile calls (so it also catches mid-operation disappearance), and the checksums claim is qualified by getChecksums().files.contains(mrk_path).
d Test intent preserved / new tests added? New stateless test 03810_missing_marks_file_error asserts the typed error and the listed wording for a column stream whose marks are in the checksums.
e Both directions demonstrated? Before this PR the same scenario produced the opaque filesystem error; with the change the read fails with Code: 226 ... does not exist on disk in part ... The file is listed in the part's checksums. Test passes 10/10.
f Fix is general, not a narrow patch? The diagnostic helper is shared by both file-access call sites (getFileSize and readFile) and branches on the checksums for both column-stream and index-stream callers, so the message is correct regardless of how mrk_path was derived. This is a diagnostic, not a guard masking an upstream bug; the underlying race is explicitly out of scope and noted in the PR.

Session id: cron:clickhouse-worker-slot-12:20260611-103400

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (fixup 839c3a1: reuse diagnostic in index-granularity loaders)

# Question Answer
a Deterministic repro? Yes. Wide: CREATE TABLE ... SETTINGS min_bytes_for_wide_part=0, INSERT, DETACH TABLE, rm a.cmrk2, ATTACH TABLE → part is broken-on-start with Code: 226 ... Marks file 'a.cmrk2' does not exist on disk in part 'all_1_1_0' ... is listed in the part's checksums. Compact: same flow on the data marks file (data.cmrk4).
b Root cause explained? Index-granularity loading reads marks directly during part load, before any query reaches MergeTreeMarksLoader: MergeTreeDataPartWide::loadIndexGranularity reads columns.front()'s marks (existsFile + getFileSize/readFile), MergeTreeDataPartCompact::loadIndexGranularity reads the data marks via readFileIfExists. If the missing/vanishing file is the granularity one, those loaders surfaced the old path-only / std::filesystem error before the new helper ran.
c Fix matches root cause? Yes. The diagnostic is extracted into a shared throwIfMarksFileMissing() and invoked from the error path of both loadIndexGranularity() callers (which hold the part's checksums/columns/name), so the same typed NO_FILE_IN_DATA_PART is produced wherever a marks file is read.
d Test intent preserved / new tests added? Test extended, not weakened. 03810 keeps the query-read case and adds an index-granularity case (remove first column's marks → reload → assert broken-on-start + the typed message in the log).
e Both directions demonstrated? Yes. With the fix the index-granularity path yields the typed message (verified in server log for Wide and Compact); without it the path emits the opaque path-only error. Existing query-read case unchanged and still passing. Runner: 15/15 with randomization.
f Fix is general, not a narrow patch? Yes. This is exactly the scope-completeness ask: the same diagnostic now covers all three marks-read sites (query-read loadMarksImpl + Wide and Compact loadIndexGranularity). The helper runs on the error path only (no successful-load overhead) and also catches a file vanishing mid-read. Not a symptom guard: it converts an already-failing read into a diagnosable error without altering control flow on success.

Session id: cron:clickhouse-worker-slot-10:20260611-133800

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (fixup d5af284 — make 03810 output locale independent)

# Question Answer
a Deterministic repro? Yes. echo "<error msg>" | grep -oF -e NO_FILE_IN_DATA_PART -e "does not exist on disk in part" -e "is listed in the part's checksums" | LC_ALL=en_US.UTF-8 sort -u deterministically prints NO_FILE_IN_DATA_PART LAST, while the committed .reference (generated under LC_ALL=C) has it FIRST. Matches the CI failure on Stateless tests (amd_llvm_coverage, 1/3), 3/3 reruns, "result differs with reference".
b Root cause explained? The query-read case piped matched phrases through sort -u. sort collation is locale-dependent: under C/POSIX the uppercase NO_FILE_IN_DATA_PART sorts before the lowercase fragments (what the reference captured), but under a UTF-8 locale (en_US.UTF-8, the CI runner default) dictionary collation case-folds, so does < is < NO_FILE and the phrase sorts last -> reference mismatch on every UTF-8-locale runner.
c Fix matches root cause? Yes. Removed sort entirely and emit each expected phrase explicitly in a fixed order. Output is now independent of both locale and the order phrases happen to appear in the message. Not a band-aid (no LC_ALL=C pin, no reference reorder, no tag change).
d Test intent preserved / new tests added? Preserved. The test still asserts all three phrases are present (a regression dropping any one still fails the reference). Assertions and the two scenarios (query-read + index-granularity) are unchanged; only the rendering of matched phrases changed.
e Both directions demonstrated? Yes. OLD sort -u form prints the wrong order under en_US.UTF-8 (the failure); NEW form prints the correct order. End-to-end against a local server: full test PASSES under LC_ALL=C, C.UTF-8 and en_US.UTF-8, and 8/8 repeated runs under en_US.UTF-8.
f Fix is general, not a narrow patch? N/A for a code bug, but applied generally: the index-granularity case never used sort (already order-stable); the only locale-dependent site was this one sort -u, now removed. No sibling test path has the same pattern.

Note on the "Server died" rows seen on the flaky-check lane: investigated the flaky-check job logs (amd_tsan run 27353273481). Those are NOT this test crashing - the server was still cold-starting (Code: 210 Connection refused, "Server replica 0 not ready" loop) before any test ran; once up, the test ran and failed with the same reference-ordering diff (no sanitizer/SIGSEGV/Fatal/LOGICAL_ERROR anywhere in the job). The same flaky-check "Server died" hit four unrelated PRs (107148, 107150, 107159, 107179) in the same window, confirming a shared slow-startup signature independent of this PR. This locale fix removes the actual deterministic failure.

Session id: cron:clickhouse-worker-slot-7:20260611-154700

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

Addresses the Stateless tests (..., flaky check) / amd_llvm_coverage failure of 03810_missing_marks_file_error on the previous head. The locale-sort fix (d5af284) cleared the deterministic UTF-8 collation failure; this fixup (16051d2) clears the remaining intermittent failure, which only appears under DB-engine randomization to Ordinary.

# Question Answer
a Deterministic repro? Yes. Run the test's Case 2 against a CREATE DATABASE ... ENGINE=Ordinary: the text_log assertion returns 0 (not 1), and the Case 1 drop table streams a CANNOT_UNLINK <Error> to client stderr. Both reproduce 100% under Ordinary, 0% under Atomic.
b Root cause explained? Two independent Ordinary-only issues. (1) The text_log filter logger_name LIKE '%t_missing_granularity_marks %' had a trailing space; the storage logger is StorageID::getNameForLogs() = db.table (uuid) under Atomic but plain db.table under Ordinary (no UUID, no trailing space), so the pattern matched under Atomic and missed under Ordinary -> count() = 0. (2) The Case 1 drop table t_missing_marks sync logs a CANNOT_UNLINK <Error> during inline directory cleanup under Ordinary (the cleanup tries to unlink b.cmrk2, which the test removed); Atomic defers physical removal to a background task so its drop is clean. With send_logs_level=error the <Error> reaches client stderr and the runner flags "having stderror".
c Fix matches root cause? Yes. (1) Drop the trailing space from the logger_name pattern -> matches both db.table (uuid) and db.table; the table name still excludes the executeQuery self-match (that logger_name does not contain the table name). (2) Run the Case 1 drop with --send_logs_level=none, the same mitigation already used on the Case 2 attach.
d Test intent preserved / new tests added? Preserved. The diagnostic assertions are unchanged: Case 1 still asserts NO_FILE_IN_DATA_PART + "does not exist on disk in part" + "is listed in the part's checksums"; Case 2 still asserts broken-on-start + the enriched message reaching text_log. No production code touched, no .reference change.
e Both directions demonstrated? Yes. OLD test under Ordinary: text_log assertion -> 0 (mismatch) and Case 1 drop -> stderr CANNOT_UNLINK. NEW test under Ordinary: text_log -> 1, stderr clean, stdout matches .reference. Verified end-to-end under both Atomic and Ordinary with CI-faithful client options (--allow_repeated_settings, send_logs_level=error), 3x stable.
f Fix is general, not a narrow patch? Yes. Checked all three drop table sites and both text_log filters in the test for the same engine-dependence: Case 2's final drop is clean under Ordinary (the broken part was already detached, so the table dir has no live part to fail cleanup on), and the query-read assertion uses fixed-order grep (no logger_name filter). Only the two sites above needed fixing.

Note: the flaky check rows that read "Server died" on earlier heads were a shared slow-cold-start signature on that lane (server not ready within the connect window, hit 4 unrelated PRs in the same window), not this test crashing; the real, test-owned signal was this Ordinary-engine reference mismatch, now fixed.

Session id: cron:clickhouse-worker-slot-2:20260611-172800

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (fixup 1b7877d)

This addresses the flaky-check / amd_debug, sequential failure of this PR's own test 03810_missing_marks_file_error on HEAD 16051d2 (the index-granularity text_log assertion returned 0 while the part was still broken-on-start).

# Question Answer
a Deterministic repro? Two fragilities reproduced deterministically against a capped local server (build 622c5bac): (1) the text_log count()>0 query throws TOO_MANY_ROWS with --max_rows_to_read=10000 on a large system.text_log (110k rows); (2) the marks-removal loop cmrk2 mrk2 mrk finds nothing when index_granularity_bytes=0 (default compress_marks=1) produces non-adaptive-compressed a.cmrk, so the part is never broken.
b Root cause explained? system.text_log grows large under the flaky check (50x repeats, heavy parallel load). The unbounded SELECT count()>0 FROM system.text_log WHERE ... is then subject to randomized read settings: a small max_rows_to_read makes it throw, and randomized parallel-read / use_query_condition_cache / implicit-projection settings can skew a count()>0 over a large system table to return 0 even though the row exists. Separately, randomized index_granularity_bytes=0 changes the marks extension to .cmrk, which the removal loop did not cover.
c Fix matches root cause? Pin the text_log read so randomization cannot skew it: SETTINGS max_rows_to_read=0, max_bytes_to_read=0, max_threads=1, use_query_condition_cache=0, optimize_use_implicit_projections=0, plus an event_date >= yesterday() partition bound (kept alongside the precise event_time window). This is the same hardening 03096_text_log_format_string_args_not_empty.sh applies. And extend both removal loops to cmrk2 mrk2 cmrk mrk so every wide-part marks extension is covered.
d Test intent preserved / new tests added? Preserved. The reference is unchanged; both cases still assert the typed NO_FILE_IN_DATA_PART diagnostic on the query-read and index-granularity paths. The pinned settings only stabilize the read of system.text_log; they do not weaken what is asserted. The extension-loop fix makes the test actually break the part (it was silently erroring out on .cmrk).
e Both directions demonstrated? Yes. OLD loop finds nothing for a.cmrk (test would error "NO MARKS FILE FOUND"); NEW loop finds it and the part is broken-on-start with assert=1. OLD text_log query throws under a read limit on a 110k-row log; NEW pinned query returns the correct result. End-to-end: 50/50 pass under full randomization (incl. parallel replicas), 5/5 with --no-random-settings, and all four wide-marks extension variants (cmrk2/mrk2/cmrk/mrk) yield broken-on-start + assert=1.
f Fix is general, not a narrow patch? Test-only change; no production code touched (the diagnostic in MergeTreeMarksLoader/Wide/Compact from earlier commits is unchanged). The fix covers both the query-read and index-granularity removal loops, all four wide marks extensions, and the timezone-robustness of the date window (verified to retain "today" from UTC-10 to UTC+14).

Session id: cron:clickhouse-worker-slot-6:20260611-202200

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (fixup 026f932)

Root cause of the flaky-check / amd_debug, sequential failures of this PR's own test 03810_missing_marks_file_error, now isolated and fixed.

# Question Answer
a Deterministic repro? Yes. clickhouse-test --diagnose-random-settings (ddmin) isolated the single culprit MergeTree setting: ratio_of_defaults_for_sparse_serialization 0.0. With it, the index-granularity case fails 13/13; without it, 0/24. All four failing CI runs (amd_debug/amd_msan sequential, amd_debug/amd_asan flaky check) carried --ratio_of_defaults_for_sparse_serialization 0.0.
b Root cause explained? With sparse serialization a column gets a .sparse.idx substream in addition to its main marks file. MergeTreeDataPartWide::loadIndexGranularity then does not read the removed main marks file, so the miss is not caught there; it surfaces later in the checksum consistency check (MergeTreeDataPartChecksum::checkSize), which throws a typed FILE_DOESNT_EXIST naming the file. The test asserted the marks-loader's NO_FILE_IN_DATA_PART message in system.text_log, which is absent on that path, so the count()>0 returned 0 while the part was still broken-on-start.
c Fix matches root cause? Yes. Pin ratio_of_defaults_for_sparse_serialization=1 on both tables so they keep dense per-column marks and deterministically exercise the marks-loader path the test targets. Two defensive hardenings in the same commit set: anchor the text_log logger_name filter on currentDatabase() (the reviewer note; matches Atomic and Ordinary, excludes other DBs), and pin the text_log read (max_rows_to_read=0, max_threads=1, etc.) since that system table can be large under flaky-check load. The marks-removal loop also now covers the .cmrk extension produced by index_granularity_bytes=0.
d Test intent preserved / new tests added? Preserved. Reference unchanged. Both cases still assert the typed NO_FILE_IN_DATA_PART diagnostic on the query-read and index-granularity paths. The sparse pin does not weaken coverage of the path under test; the sparse path has its own clean typed diagnostic (FILE_DOESNT_EXIST), so the PR's "no opaque std::filesystem error" contract still holds there.
e Both directions demonstrated? Yes. Before: ddmin 13/13 fail with ratio_of_defaults_for_sparse_serialization 0.0; the sparse case logs FILE_DOESNT_EXIST (our message absent, count()>0=0). After: 60/60 pass under full MT randomization, 3/3 with --no-random-settings, and --diagnose-random-settings over 80 runs reports no diagnosable failure.
f Fix is general, not a narrow patch? Test-only change; no production code touched. The earlier-commit production diagnostic in MergeTreeMarksLoader/Wide/Compact is unchanged. The sparse path already produces a clean, typed, file-naming error via checksum validation, so no new opaque-error path is left undiagnosed. Whether to additionally route the sparse index-granularity path through the same enriched NO_FILE_IN_DATA_PART helper is a larger substream-aware change and is intentionally left out of this test-stabilization fix.

Session id: cron:clickhouse-worker-slot-6:20260611-202200

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

This fixup (f21bb21) is a test-only change: it adds compact-part coverage (Case 3) to 03810_missing_marks_file_error.sh for the MergeTreeDataPartCompact::loadIndexGranularity diagnostic path. The production code already wraps that path (839c3a1); this closes the test-coverage gap raised in review.

# Question Answer
a Deterministic repro? Yes. Removing the single compact data marks file from a detached compact part and re-attaching deterministically yields broken-on-start + the typed NO_FILE_IN_DATA_PART message. Verified on demand on a capped local server; a control with the marks file left intact attaches clean (no broken part), confirming the case genuinely drives the compact loader.
b Root cause explained? The PR's contract is "all marks-read sites produce the enriched diagnostic". Index-granularity loading reads marks directly on part load: wide parts via loadIndexGranularityImpl (first column marks), compact parts via readFileIfExists on the single data marks file. Case 2 covered only the wide path; the compact path (different file, different read API) was untested.
c Fix matches root cause? Yes. Adds a compact-part case mirroring Case 2: force a compact part, remove its data marks file, re-attach, assert broken-on-start + the enriched message in system.text_log. No production change; it tests the existing 839c3a1 wrap.
d Test intent preserved / new tests added? Preserved and extended. Cases 1 and 2 are unchanged; Case 3 is added. A throwIf(part_type != 'Compact') guard ensures the compact loader is actually exercised, and the marks-file loop covers .cmrk4 / .mrk4 / .cmrk3 / .mrk3.
e Both directions demonstrated? Yes. With the file removed: broken-on-start + enriched message present (the asserted output). Control with the file intact: clean attach, SELECT count() = 1000, no broken part. 0 failures across Atomic + Ordinary x compress_marks 0/1 x sparse 0.0/1.0 under en_US.UTF-8, and 10/10 full-test runs on both engines.
f Fix is general, not a narrow patch? N/A in the production sense (test-only). For coverage completeness: the marks-removal loop covers all four compact extensions; the text_log filter is anchored on currentDatabase() so it matches both Atomic (db.table (uuid)) and Ordinary (db.table) logger names; read settings are pinned as in Case 2.

Session id: cron:clickhouse-worker-slot-2:20260611-214800

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI fully finished on HEAD f21bb210884c (Finish Workflow SUCCESS). No PR-caused failures.

CI ledger (covered SHA f21bb21):

  • Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / test_storage_rabbitmq::test_rabbitmq_big_message — FAIL — chronic flaky, NOT PR-caused (CIDB 30d: 8 hits / 6 unrelated PRs + 3 master; RabbitMQ big-message delivery timing under sanitizers). This PR only adds a MergeTreeMarksLoader diagnostic + a stateless test — unrelated to RabbitMQ. Tracked separately.
  • The prior-HEAD flaky-check / arm_tidy / style failures were all addressed in commits up to f21bb21 (the 5 clickhouse-gh[bot] CRs); current HEAD has none of them.
  • All other checks green.

All failures explained + tracked, none PR-caused. Ready for review. cc @CurtizJ @alesapin (comp-mergetree).

Session: cron:our-pr-ci-monitor:20260612-023000

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI summary for HEAD f21bb210884c: the new regression test 03810_missing_marks_file_error passes the flaky check 25/25 across all sanitizers (amd_debug/asan/tsan/msan) and all sequential jobs. The one red integration check, test_storage_rabbitmq/test.py::test_rabbitmq_big_message (amd_asan_ubsan, db disk, old analyzer, 6/6), is a pre-existing chronic flaky (6 PRs + 3 master in 30d), unrelated to this PR (which only touches MergeTreeMarksLoader.cpp); tracked separately. The Mergeable Check/PR aggregators are red only because of that flaky integration test. No PR-caused failures. Ready for review.

Session: cron:our-pr-ci-monitor:20260612-033000

groeneai and others added 9 commits June 20, 2026 07:25
…on disk

MergeTreeMarksLoader::loadMarksImpl() computes the marks file path from the
part's own checksums (getStreamNameForColumn only returns a stream name that is
present in the part's checksums), so the file is expected to exist on disk. When
it does not, getFileSize() surfaces an opaque

    std::filesystem::filesystem_error: in file_size: No such file or directory [.../<col>.cmrk2]

(Code 1001) with no indication of which part is affected or what its on-disk
state is. This shows up in the flaky integration test
test_rename_column::test_rename_distributed_parallel_insert_and_select under
heavy concurrent RENAME COLUMN + INSERT + SELECT load, where it is impossible to
diagnose from the message alone.

Check for the file's existence before calling getFileSize() and, when it is
missing, throw NO_FILE_IN_DATA_PART with the part name, path, columns, the files
listed in the part's checksums, and the actual on-disk listing. The check runs
only on the error path, so successful reads are unaffected.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…and qualify the checksums claim

Two review points on the marks-file diagnostic:

1. The previous standalone existsFile precheck did not help the concurrent
   race the PR targets: if the file disappeared after the probe but before
   getFileSize/readFile, the opaque std::filesystem error was still surfaced.
   The diagnostic is now raised from the catch path of the actual getFileSize
   and readFile operations (re-probing existsFile), so it also fires when the
   file vanishes mid-operation.

2. The message asserted unconditionally that the file is "listed in the part's
   checksums", but loadMarksImpl does not verify that and other callers build
   the marks path from index stream names rather than column checksums. The
   wording now branches on getChecksums().files.contains(mrk_path) ("listed" vs
   "NOT listed"), so it does not mislead about metadata-vs-disk for non-column
   callers.

The stateless test 03810_missing_marks_file_error removes a column stream's
marks file (which is in checksums) and asserts both the typed error and the
"listed" wording.
The previous review-fixup commit (91c0bc2) introduced two CI failures on its
own diff:

1. arm_tidy / clang-tidy under -Werror: refactoring the file access into the
   throwIfMarksFileMissing lambda left `size_t file_size;` declared without an
   initializer, which cppcoreguidelines-init-variables rejects. Initialize it
   to 0 at the declaration (matches how master declared it before the PR).

2. Style check (various): the new stateless test issues SYSTEM DROP MARK CACHE,
   which touches server-wide shared state, so various_checks.sh requires the
   no-parallel tag. Add no-parallel to the test's Tags line.

No behavior change: the diagnostic and the regression test assertions are
unchanged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The typed NO_FILE_IN_DATA_PART diagnostic only fired in
MergeTreeMarksLoader, which is reached on query reads. Part index-granularity
loading reads marks directly: MergeTreeDataPartWide::loadIndexGranularity reads
the first column's marks file (standalone existsFile + getFileSize/readFile),
and MergeTreeDataPartCompact::loadIndexGranularity reads the "data" marks file
via readFileIfExists. If the missing or vanishing file is the one selected for
granularity, those loaders surfaced the old path-only / std::filesystem error
before the helper ran.

Extract the diagnostic into a shared throwIfMarksFileMissing() and call it from
the error path of both loadIndexGranularity() callers (which hold the part's
checksums, columns and name), so a missing granularity marks file yields the
same diagnosable NO_FILE_IN_DATA_PART error. The helper runs on the error path
only, so a successful load pays nothing, and wrapping the read in the caller
also catches the file disappearing mid-read.

03810_missing_marks_file_error now also covers the index-granularity path: it
removes the first column's marks file, reloads the table, and asserts the part
becomes broken-on-start and the typed message reaches the log.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The query-read case piped the matched error phrases through `sort -u`.
`sort` collation depends on the active locale: in the C/POSIX locale the
uppercase `NO_FILE_IN_DATA_PART` sorts before the lowercase message
fragments (which is what the committed .reference was generated with),
but on a UTF-8 locale (en_US.UTF-8, the CI runner default) dictionary
collation case-folds and orders `does`/`is` before `NO_FILE...`, so the
phrase came out last and the test failed the reference comparison
deterministically on every UTF-8-locale runner (seen on the
amd_llvm_coverage stateless check, 3/3 reruns).

Drop `sort` and emit each expected phrase explicitly in a fixed order, so
the output is independent of both locale and the order the phrases happen
to appear in the error message. No .reference change is needed; the
index-granularity case never used `sort` and is unchanged.

Verified the test passes under LC_ALL=C, C.UTF-8 and en_US.UTF-8, and
8/8 repeated runs under en_US.UTF-8; confirmed the old `sort -u` form
fails under en_US.UTF-8 while the new form passes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The flaky check fails ~1/N under DB-engine randomization to Ordinary, for
two independent reasons, both in the index-granularity / cleanup paths the
test exercises:

1. The text_log assertion filtered logger_name LIKE '%t_missing_granularity_marks %'
   with a trailing space. The storage logger name is StorageID::getNameForLogs(),
   which is 'db.table (uuid)' under Atomic but plain 'db.table' under Ordinary
   (no UUID suffix, no trailing space). So the trailing-space pattern matched
   under Atomic but missed under Ordinary, and count() returned 0 instead of 1.
   Drop the trailing space; the table name is still specific enough to skip the
   query's own 'executeQuery' log row (whose logger_name does not contain the
   table name).

2. The Case 1 'drop table t_missing_marks sync' streamed a CANNOT_UNLINK <Error>
   to client stderr under Ordinary: the part directory cleanup tries to unlink
   b.cmrk2, which the test removed. Atomic defers physical removal to a
   background task, so the synchronous drop is clean there, but Ordinary removes
   inline and logs the error at <Error>, which the runner (send_logs_level=error)
   treats as a stderr failure. Run that drop with --send_logs_level=none, the
   same mitigation already used on the Case 2 attach.

No production code change; the diagnostic itself is unchanged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…nsions

The flaky check failed the index-granularity case: under randomized settings the
text_log assertion returned 0 while the part was still detached broken-on-start.

Two independent fragilities, both fixed in the test only:

1. The text_log scan was unbounded against randomized read settings. system.text_log
   grows large under the flaky check (50x repeats under heavy load), so a randomized
   max_rows_to_read makes the count() query throw TOO_MANY_ROWS, and parallel-read /
   query-condition-cache / implicit-projection randomization can skew a count()>0 on a
   large system table. Pin the read: max_rows_to_read=0, max_bytes_to_read=0,
   max_threads=1, use_query_condition_cache=0, optimize_use_implicit_projections=0, and
   add an event_date>=yesterday() partition bound (kept alongside the precise event_time
   window; verified to retain "today" across timezones from UTC-10 to UTC+14). This is
   the same hardening 03096_text_log_format_string_args_not_empty.sh applies.

2. The marks-file removal loops only tried cmrk2/mrk2/mrk, missing non-adaptive
   compressed marks (.cmrk) produced when randomized index_granularity_bytes=0 with
   compress_marks=1. The loop now also covers .cmrk, so the intended marks file is
   always removed and the part is genuinely broken.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ratio_of_defaults_for_sparse_serialization=0.0 was the actual cause of the
flaky-check / amd_debug-sequential failures (confirmed by ddmin: it reproduces
13/13 with that setting, 0/24 without, and all four failing CI runs carried
--ratio_of_defaults_for_sparse_serialization 0.0).

With sparse serialization a column gets a .sparse.idx substream; loadIndexGranularity
does not read the removed main marks file, so the missing file is caught later by the
checksum consistency check, which throws a typed FILE_DOESNT_EXIST naming the file (a
clean error, not the opaque std::filesystem one this PR removes) rather than the marks
loader's NO_FILE_IN_DATA_PART. The test asserted the marks-loader message, so it failed.
Pin ratio_of_defaults_for_sparse_serialization=1 so both tables keep dense per-column
marks and deterministically exercise the marks-loader path under test.

Also addresses the review note on the text_log filter: anchor logger_name on
currentDatabase() so it matches both Atomic ('db.table (uuid)') and Ordinary ('db.table')
and excludes a same-named table from another test's database in the server-wide text_log.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The production change wraps both MergeTreeDataPartWide::loadIndexGranularity
and MergeTreeDataPartCompact::loadIndexGranularity with the typed
NO_FILE_IN_DATA_PART diagnostic, but 03810 only forced wide parts
(min_bytes/min_rows_for_wide_part = 0), so the compact loader was never
exercised. The compact path keeps all marks in a single "data" marks file and
reads it through a different API (readFileIfExists), so it needs its own
coverage for the PR's "all marks-read sites produce the enriched diagnostic"
contract.

Add a compact-part case: force a compact part with large
min_*_for_wide_part, guard that the part really is Compact, remove the single
"data" marks file (covering the .cmrk4 / .mrk4 / .cmrk3 / .mrk3 extensions),
re-attach the table, and assert the part is broken-on-start and the enriched
NO_FILE_IN_DATA_PART message reached system.text_log. The text_log filter is
anchored on currentDatabase() so it matches both Atomic ('db.table (uuid)')
and Ordinary ('db.table') logger names, and the read settings are pinned for
the same reasons as the wide case.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the groeneai/improve-missing-marks-file-error branch from f21bb21 to f58ec14 Compare June 20, 2026 07:41
@groeneai

Copy link
Copy Markdown
Collaborator Author

Rebased onto current master (was conflicting). The only conflict was in MergeTreeMarksLoader::loadMarksImpl, where master's #106675 added a marks_count == 0 early-return next to this PR's missing-marks diagnostic; resolved by keeping both (early-return first, then the typed NO_FILE_IN_DATA_PART conversion on the file-access error path). No other files conflicted; the net diff is unchanged (4 src + 2 test files).

Verified on the rebased branch (local debug build, build id a4f656c9): 03810_missing_marks_file_error passes 6/6 across {C, C.UTF-8, en_US.UTF-8} x {Atomic, Ordinary} and 12/12 repeated runs, stderr clean. The enriched diagnostic fires at all three marks-read sites (query read, wide and compact index-granularity loaders).

Force-pushed f21bb21 -> f58ec14, so the bot's earlier inline-comment SHA anchors have shifted; all five prior review points remain addressed.

reader = std::make_unique<CompressedReadBufferFromFile>(std::move(buffer));
try
{
auto buffer = data_part_storage->readFile(mrk_path, read_settings.adjustBufferSize(file_size), file_size);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This catch still misses the same missing-file race when use_reader_executor=1. Context::getReadSettings() propagates that setting into MergeTreeMarksLoader, and then ReadPipeline::build() returns a PipelineReadBuffer whose ReaderExecutor opens and reads the local file later from reader->readStrict(...), after this try block has already finished. A file that exists for getFileSize()/readFile() but disappears before the first actual read will therefore still surface the lower-level file-open/read exception instead of this NO_FILE_IN_DATA_PART diagnostic. Please keep the actual marks decoding (readStrict / readBinaryLittleEndian loop) under the same error conversion, or otherwise disable the reader-executor path for marks files, so the diagnostic covers the deferred-read path too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Confirmed on current master, and not fixed in this PR yet. Explaining why, since the answer is "the fix is easy, proving it is not".

Your reading of the path is right: ReadPipeline::tryBuildReaderExecutor still returns a lazy PipelineReadBuffer for a local marks file with no caches or async prefetch configured, that buffer opens nothing on construction, and the real open plus first read happen inside the mark-decoding loop. That loop is outside the try, so a file that vanishes between getFileSize and the first read surfaces the lower-level error rather than NO_FILE_IN_DATA_PART.

I implemented option (a) (wrap the decoding loop in the same conversion, builder and plain_marks staying in the enclosing scope so the post-decode builder->finish is unchanged) and it built clean. Then I mutation-tested it: reverted only that try/catch, rebuilt, confirmed the Build ID moved and that the server actually loaded the mutant, and re-ran 03810. The output was byte-identical and the test still passed.

So 03810 cannot currently prove the deferred catch. It removes the marks file before the query starts, so loadMarksImpl fails at its first getFileSize and the decoding loop is never reached. Isolating the deferred path needs the file to exist at sizing and be gone at the deferred open, which is a genuine TOCTOU: there is no pauseable failpoint anywhere in that read path today, so it needs new production failpoint plumbing plus concurrent-query orchestration.

Rather than ship a code change I cannot back with a test, I have dropped it from this PR and will land the failpoint and the fix together in a follow-up. This PR stays what its description claims: the eager-path diagnostic, plus the test.

This push is test-only. It fixes a real PR-caused failure the flaky check found: the CI merge-tree randomizer injects min_bytes_for_full_part_storage, and on a high draw choosePartFormat selects packed part storage, which bundles the whole part into one data.packed archive, leaving no separate marks file for the test to remove. That reproduced 5/5 on both amd_debug and amd_asan_ubsan. The test now pins min_bytes_for_full_part_storage = 0, which is the honest scope: it asserts a marks file listed in the checksums is missing on disk, a state that only exists in full part storage. 50/50 runs pass with the setting redrawn from the randomizer's own distribution each time, 13 of those draws being the packed-selecting maximum.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finished on f723193b4a20. Failure dispositions:

No PR-caused failures remain on this head.

groeneai added 3 commits July 29, 2026 02:52
The CI merge-tree randomizer injects `min_bytes_for_full_part_storage`
(`tests/clickhouse-test`, `threshold_generator(0.3, 0.3, 0, 512 MiB)`), and when it
draws a value above the part size `MergeTreeData::choosePartFormat` selects
`PartStorageType::Packed`. A packed part bundles every file into a single
`data.packed` archive, so the part directory holds no separate `.cmrk2`/`.mrk2`
marks file for the test to remove: the locator matched zero files, printed
`NO MARKS FILE FOUND`, and the test exited 1.

This was deterministic once the setting was drawn, not flaky: the flaky check
reproduced it 5/5 on both `amd_debug` and `amd_asan_ubsan`.

The test is specifically about a marks file that is listed in a part's checksums
but missing on disk, which only exists in full part storage, so pin
`min_bytes_for_full_part_storage = 0` on all three tables. An explicit per-DDL
setting wins over the randomizer: `ClientBase::addMergeTreeSettings` only injects
a setting when the `CREATE` query does not already set it.
A missing marks file raises a `NO_FILE_IN_DATA_PART` exception, which release
builds handle normally, so "crashing with" was the wrong word for the behaviour
this comment contrasts against.
Per the repository conventions, literal class and function names belong in inline
code blocks, and a function is written as `f` rather than `f()`.
@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements and removed pr-ci labels Jul 29, 2026
const String & part_name,
const String & mrk_path)
{
if (data_part_storage.existsFile(mrk_path))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

throwIfMarksFileMissing is using data_part_storage.existsFile(mrk_path) as the source of truth, but that is only a metadata probe on object-storage-backed parts. DiskObjectStorage::existsFile delegates to metadata_storage->existsFile (src/Disks/DiskObjectStorage/DiskObjectStorage.cpp), and MetadataStorageFromPlainRewritableObjectStorage::existsFile just checks the local snapshot (src/Disks/DiskObjectStorage/MetadataStorages/PlainRewritable/MetadataStorageFromPlainRewritableObjectStorage.cpp).

If the marks blob is gone from S3/Azure while the part metadata still lists it, getFileSize still succeeds from metadata and the first real failure happens only on the later remote read. In that case this helper returns early and we still surface the lower-level storage exception instead of the new NO_FILE_IN_DATA_PART diagnostic, so the PR's storage-agnostic contract is still broken for object-storage MergeTree parts.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Confirmed the chain by reading, with one correction to where the gap actually sits.

Verified: DiskObjectStorage::existsFile (DiskObjectStorage.cpp:245) delegates to metadata_storage->existsFile and never touches the object store, and MetadataStorageFromPlainRewritableObjectStorage::existsFile answers from FsSnapshot under a mutex (FsSnapshot.cpp:367). getFileSize is metadata too: the plain rewritable variant reads bytes_size out of that same snapshot, and MetadataStorageFromDisk::getFileSize is getTotalSize(readMetadata(path)->objects). readFile is lazy as well, since DiskObjectStorage::prepareRead only resolves getStorageObjects and the CompressedReadBufferFromFile constructor performs no read. So with the blob gone and the metadata intact, none of those three calls fails.

The correction: in that state throwIfMarksFileMissing is not returning early, it is never invoked. Both of its call sites are catch (...) handlers, one around getFileSize (MergeTreeMarksLoader.cpp:171) and one around readFile (:205). The first real reads are readStrict and readBinaryLittleEndian at :255, :263, :297 and :298, all outside both try blocks. Since neither guarded call throws, neither handler runs, so the probe never gets to answer. The defect is the placement of the conversion site, not the probe.

That makes this the same defect as the deferred read reported in the other thread, reached from a different carrier: the failure lands in the decoding loop, outside the try. Object storage does not add a second defect, it widens the carrier set from a local removal race to any part whose metadata outlives its blob.

One narrowing: the metadata implementations diverge, so "object-storage-backed parts" is wider than the evidence. MetadataStorageFromPlainObjectStorage::existsFile (Plain/MetadataStorageFromPlainObjectStorage.cpp:49) does call object_storage->exists, so for that variant the probe returns false and the existing conversion already fires. The snapshot-backed and local-metadata variants are the carriers.

New information relative to my other reply: this carrier is reproducible without the pauseable failpoint that blocked the local one. tests/integration/test_checking_s3_blobs_paranoid/test.py:797 already removes a blob with minio_client.remove_object while the metadata survives, and asserts the resulting error is the lower-level The specified key does not exist. This error happened for S3 disk, which is exactly the opaque shape this change set out to replace. So the fix and a test that can actually distinguish it are able to land together, which is what the follow-up covers. I am not pushing the code change here: per the no-speculative-changes rule it ships with the test that proves it, not ahead of it.

@clickhouse-gh

clickhouse-gh Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.30% 86.40% +0.10%
Functions 91.90% 91.90% +0.00%
Branches 78.50% 78.50% +0.00%

Changed lines: Changed C/C++ lines covered: 69/78 (88.46%) · Uncovered code

Full report · Diff report

@groeneai

groeneai commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 5fdff6a

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 01666_merge_tree_max_query_limit flaky under parallel replicas; a fresh trunk regression, with dozens of unrelated PRs and master hits in the last 24h #112385 (mine, open)
Stress test (amd_asan_ubsan) / UndefinedBehaviorSanitizer: undefined behavior (STID: 0250-3bba) signed integer overflow on the origin + offset addition in toStartOfInterval; trunk bug, 28 unrelated PRs plus a master hit in 30d #112045 (external, open)
Stress test (arm_msan) / Hung check failed, possible deadlock found chronic trunk hung-check deadlock, 477 distinct PRs and 225 master hits in 30d. The merged partial fix #111909 covers only the random-distribution sub-cause, and master has kept failing after it merged, so it does not own this run a fix task is pending (investigating the post-#111909 residual at full effort - fixing-PR link to follow here)
Sync - CH Inc sync (private, not actionable by me)

All four flavours of the flaky check job pass on this head, so the test this PR adds is not
itself flaky.

Session id: cron:our-pr-ci-monitor:20260729-093000

@groeneai groeneai added the groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR label Aug 19, 2026
@abashkeev abashkeev added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Sep 4, 2026
groeneai and others added 5 commits September 5, 2026 16:25
The previous run on this head reported 174 checks with 172 of them skipped:
the Config Workflow job could not reach the CI database, timed out, and
praktika then dropped every dependent job. No test ever executed, so the run
carried no signal about this branch.

This commit changes nothing. Its tree is byte identical to its parent and it
exists only to raise a fresh pull_request synchronize event. I add it on top
rather than amending or rebasing, because the parent is a maintainer's signed
merge commit and rewriting it would drop that merge parent.
Resolves the conflict in `MergeTreeDataPartCompact::loadIndexGranularity`
introduced by master's shared-part-schema refactor.

Master moved the part schema behind accessors: the raw `columns` member is now
reached through `getColumns`, and `columns_substreams` became a `shared_ptr`
reached through `getColumnsSubstreams`. Both sides of the conflict call
`loadIndexGranularityImpl` with the same arguments; only the spelling of the
column accessors differs. The resolution keeps this branch's `try`/`catch`
wrapper and adopts master's accessor spelling inside it.

`MergeTreeDataPartWide::loadIndexGranularity` merged without a textual
conflict but needed the same adaptation: the `throwIfMarksFileMissing` call
this branch added still passed the removed `columns` member, which no longer
compiles, so it now passes `getColumns` as well.

A merge is used rather than a rebase: the previous head is a maintainer commit
and the repository guidance is to add new commits rather than rewrite history.

Co-Authored-By: Claude Opus 5 <[email protected]>
`03810_missing_marks_file_error.sh` deletes a marks file out of a live part
directory. Master now forbids that in stateless tests: the
`server_data_manipulation_in_stateless_tests` style check, added in
`e1fc810cb6803de`, rejects a stateless `.sh` test that resolves a server-side
path from a system table and then runs a file-modifying command, because
stateless tests run against arbitrary server configurations (object storage,
shared MergeTree, encrypted disks). The check's companion sweep converted the
other offenders to integration tests; this test predates the check and escaped
it only because the branch was not merged.

The three cases move over unchanged in substance, one per production call site
the diff touches: the query read path through `MergeTreeMarksLoader`, and the
index-granularity load path for wide and for compact parts. A single plain
local-disk node replaces the original's `no-object-storage`,
`no-shared-merge-tree` and `no-replicated-database` tags, and also its
`no-parallel` tag, which was only needed because `SYSTEM DROP MARK CACHE` is
server-wide.

Both load-path cases assert on `system.text_log` rather than only on
`system.detached_parts.reason`: `reason` is `broken-on-start` whether the load
failed with the typed diagnostic or with the opaque `std::filesystem` error, so
it cannot separate the two.

Verified in both directions. With the change, the three cases pass. With only
the four production files reverted to master and the tests left untouched, all
three fail, and each fails on its own assertion: the read path reports
`Code: 1001 ... std::filesystem::filesystem_error: in file_size: No such file`
instead of `NO_FILE_IN_DATA_PART`, and both load paths find no matching
`text_log` row.

Co-Authored-By: Claude Opus 5 <[email protected]>
The converted test checked the exception name and a few generic phrases, so it
would still have passed if the part name, the missing marks file, the columns,
the checksums listing or the on-disk listing had been dropped from the message.
Those fields are the entire point of the change, so each case now asserts them.

The marks file is asserted together with its `Marks file '...'` prefix. The bare
name is not enough: it also appears in the `Checksums files:` listing later in
the same message, where its presence says nothing about which file was reported
missing.

Each case asserts the marks file its own production path is expected to resolve:
`b` for the query read path, which reads only that column, the first column `a`
for the wide index-granularity path, and the single `data` marks file for the
compact one. That last assertion is what pins the compact case to
`MergeTreeDataPartCompact::loadIndexGranularity`, since the wide path would have
named a per-column marks file instead.

Two mechanics the earlier version got wrong. A load failure is logged both as
the diagnostic and again wrapped in the broken-part report, so selecting one row
by recency can pick the wrapper; all matching rows are now joined before
asserting. And a message read back out of `system.text_log` arrives escaped, so
the quote escaping is undone first, which lets the same assertions serve both a
logged message and a client-side error string.

Re-verified in both directions: three pass with the change, and all three fail
with only the four production files reverted to master.

Co-Authored-By: Claude Opus 5 <[email protected]>
Asserting only the `Checksums files:` and `Files on disk:` labels left their
contents unchecked, so the listings could have been empty, truncated or built
from the wrong part and the test would still have passed.

Each case now asserts that the missing marks file appears in the checksums
listing, that it does not appear in the on-disk listing, and that the stream's
surviving `.bin` data file does. Those three together are the diagnostic's
actual claim: the part's checksums expect a file that is not there, while the
rest of the part is intact. The `.bin` assertion is what keeps the on-disk
listing pinned to the part's real contents rather than to an empty list.

Re-verified in both directions with the same two binaries: three pass with the
change, and all three fail against a build with only the four production files
reverted to master.

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

groeneai commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

Merged master, and moved this PR's test into tests/integration.

Why no CI has run here since July: the branch had been conflicting since 2026-08-04, and while it conflicted GitHub could not compute refs/pull/107150/merge, which is the ref the pull_request workflow checks out. The run on the previous head reported 174 jobs, 172 of them skipped, and produced no test results at all. That merge ref had been frozen at 2026-08-04T16:02Z and is recomputed as of this push, so the checks now starting are the first real signal on this branch in five weeks.

I merged master rather than rebasing, so the two existing master merges in this branch stay in the history. The only textual conflict was in MergeTreeDataPartCompact::loadIndexGranularity, where master moved the part schema behind getColumns and getColumnsSubstreams. MergeTreeDataPartWide auto-merged without a conflict but needed the same accessor change, since the throwIfMarksFileMissing call this branch adds still passed the removed columns member and would not have compiled.

The stateless test 03810_missing_marks_file_error is now tests/integration/test_missing_marks_file. It deletes a marks file out of a live part, which server_data_manipulation_in_stateless_tests has forbidden since 2026-08-09; this test predates that check and escaped its sweep only because the branch had not merged. It covers one case per production call site the diff touches: the query read path, and the index-granularity load path for wide and for compact parts.

Verified in both directions. The three cases pass, and against a build with only the four production files reverted to master all three fail: the read path on the original Code: 1001 ... in file_size: No such file, and both load paths on the diagnostic being absent from system.text_log. Each case asserts the payload rather than just the exception name, including that the missing marks file is in the part's checksums listing and absent from its on-disk listing.

@clickhouse-gh

clickhouse-gh Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 6ac8ededc with master bcaec2e05 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

6 object files changed (+27.72 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeMarksLoader.cpp.o 191.69 KiB 216.91 KiB +25.23 KiB (+13.16%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

291 translation units recompiled, 2869 s compile time in total, 291 of them have a recent master baseline.

Job report

@groeneai

groeneai commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 6ac8ede

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
AST fuzzer (amd_debug, targeted) / Server unresponsive: memory limit exceeded Container-cgroup OOM, and the allocation that tripped it was the job's own diagnostics. dmesg says gdb invoked oom-killer with constraint=CONSTRAINT_MEMCG, and at that instant the memcg held clickhouse-serv at 44.47 GiB plus two concurrent gdb processes at 4.20 and 4.23 GiB, i.e. 52.9 GiB against this job's --memory=57740840960 (53.78 GiB) cap. The kernel then killed clickhouse-serv (oom_score_adj:555), so the client reported Lost connection to the server. Not reachable from this PR's diff: the last fuzzed AST is a numbers_mt scan with no MergeTree table, no parts and no marks, and the signature spans 25 rows over 16 distinct pull requests and 0 true-master runs in 30 days. a fix task is created (investigating at full effort - fixing-PR link to follow on this PR)
PR rollup of the AST fuzzer row above, not a second defect a fix task is created (the same one; its fixing-PR link will be posted here)
Sync - CH Inc sync (private, not actionable by me)

Nothing else failed: 174 check-runs, 146 success / 25 skipped, and the praktika tree is 172 nodes with
0 DROPPED, so this is a real run rather than a dropped matrix. Finish Workflow, Config Workflow,
Style check and Mergeable Check are all success.

For the record, and so a later pass does not re-link it: my merged #116782 ("Reserve host memory for
the CI runner agent in the fuzzer jobs") is present on this head (behind_by=0 against its merge
commit, and its --memory flag is visible in this run's job.log). It fixed the different, host-level
failure where the runner was reclaimed and no result was published at all. Here the runner survived
and a result was published, so the containment worked; what it does not size is the diagnostic memory
inside that same budget. #116359 is diagnosability only and raises no limit, so it is not the owner
either.

Session id: cron:our-pr-ci-monitor:20260906-000110

@groeneai

groeneai commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the AST fuzzer (amd_debug, targeted) container-OOM (Server unresponsive: memory limit exceeded) on 6ac8eded: #118365. The container memory cgroup ran out, not the server: the job keeps two resident gdb -batch inside it, 8.4 GiB of a 53.78 GiB budget, and the kernel picked the server as the victim. Nothing in that failure touches this PR's diff.

@groeneai

groeneai commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 6ac8ede (owner update)

The fixing PR I named for this head on 09-06, #118365, is closed unmerged, so those two rows need a new owner. Re-measured from this run's own dmesg.log:

Check / test Reason Owner / fixing PR
AST fuzzer (amd_debug, targeted) / Server unresponsive: memory limit exceeded container-memcg OOM: clickhouse-serv alone at 44.47 GiB anon-rss inside the 53.78 GiB container cap, 4.1 GiB over the 40.33 GiB ceiling it derives for itself; not caused by this PR #118467 (external, open)
PR rollup of the AST fuzzer row above, not a second defect #118467 (external, open)
Sync - CH Inc sync (private, not actionable by me)

Two corrections to that 09-06 note, since I was the one who overstated it:

#118467 bounds the path-glob expansion measured on the sibling head of this descriptor; this run's server.log is no longer downloadable, so I cannot say the same trigger fired here. Either way nothing in the failure touches this PR's diff.

@clickhouse-gh clickhouse-gh Bot added comp-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... and removed comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Nov 19, 2026

This branch has not been deployed

No deployments
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-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants