Skip to content

Do not read the master-only system.parts.files column in 04550_restore_fsync_after_insert - #115117

Merged
PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04550-no-system-parts-files
Aug 18, 2026
Merged

PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04550-no-system-parts-files

Conversation

@groeneai

@groeneai groeneai commented Aug 17, 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):

...

Description

04550_restore_fsync_after_insert.sh (added by #111378) read the files column of
system.parts to size the encrypted-incremental-restore fsync assertion. That column was added
by 476e9fc in January, after 25.8 forked, so the automated 25.8 backport #115088 fails at
runtime even though the cherry-pick applied cleanly and the script is byte-identical:

Code: 47. Unknown expression identifier `files` in scope
  SELECT files FROM system.parts WHERE ... AND (`table` = 't_restore_fsync_enc'). (UNKNOWN_IDENTIFIER)
Code: 32. Attempt to read after eof: value  cannot be parsed as UInt64 for query parameter 'files'.

CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115088&sha=980e9739e2ff0687cec113ed6460d38af75034f6&name_0=BackportPR&name_1=Stateless%20tests%20%28amd_asan%2C%20distributed%20plan%2C%20parallel%2C%201%2F2%29

The count the assertion wants is how many files RESTORE copies and must therefore fsync. The test
already measures exactly that for its first table, with SELECT path FROM system.parts plus
find. This drops the system.parts.files read and feeds the encrypted arm the same count. The
two tables have identical schema, data and part-layout settings, so their parts hold the same file
set; the assertion gets stronger, since the physical count also covers checksums.txt,
columns.txt and the zero-byte arr.bin that the checksums map does not enumerate. .reference
is unchanged.

Validation: on the official 25.8 binary the old test reproduces both errors above and the new one
runs to completion. On master the encrypted restore performs 20 FileSync events against a
required 18, and the two arms' part file lists are identical on both branches (18 files on master,
15 on 25.8), so the reuse does not depend on a master-specific layout. Disabling
fsync_after_insert on the encrypted table still fails the test, so the assertion is not vacuous.
50/50 runs green with randomized settings.

Note that #115088 cannot pick this up by regeneration: the backport tree is built from #111378's
merge commit, so a regenerated backport carries the same broken line.

Version info

  • Merged into: 26.8.1.1602 (included in 26.8 and later)

…e_fsync_after_insert

The test read the `files` column of `system.parts` to size the
encrypted-incremental-restore fsync assertion. That column was added by
476e9fc in January, after 25.8 forked, so the automated 25.8
backport of ClickHouse#111378 (ClickHouse#115088) fails at runtime with UNKNOWN_IDENTIFIER
even though the cherry-pick applied cleanly and the script is
byte-identical to master. The empty shell variable then also fails the
`{files:UInt64}` parameter binding.

The count the assertion wants is how many files RESTORE copies and must
therefore fsync. The test already measures exactly that for its first
table via `SELECT path FROM system.parts` plus `find`, so feed the
encrypted arm the same count and drop the column read. The two tables
have identical schema, data and part-layout settings, so their parts hold
the same file set; the physical count is also larger than the checksums
map (18 vs 14 on master), since it covers checksums.txt, columns.txt and
the zero-byte arr.bin, so the assertion gets stronger rather than weaker.

Validated on the official 25.8 binary: the old test reproduces both
errors, the new one runs to completion. On master the encrypted restore
performs 20 FileSync events against a required 18, the two arms' part
file lists are identical on both branches (18 files on master, 15 on
25.8), disabling fsync_after_insert still fails the test, and 50/50 runs
pass with randomized settings.

Related: ClickHouse#111378
Related: ClickHouse#115088

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

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

An independent model reviewed this diff cold, plus my own cold review of the resulting code.
Verdicts below; nothing was left unresolved.

⚠️ Arm 3 compares a raw FileSync total, not an on/off delta (test-liveness) - disagree

The claim: because the encrypted arm asserts ProfileEvents['FileSync'] >= {files:UInt64} on the
raw total rather than on an on/off delta like arm 1, unrelated backup-side sync events could mask
an omitted part-file sync.

The shape is accurate, but it is arm 3's pre-existing design from #111378 and this diff strictly
improves it. git diff <base>..HEAD touches no line of that assertion except the parameter value,
and the value moves the bound up: on master the encrypted restore performs 20 FileSync events,
the old bound (system.parts.files, i.e. checksums.files.size()) was 14, the new bound
($copied_files) is 18. Tolerated omissions therefore drop from 6 to 2.

More decisively, the regression this oracle exists to catch cannot be partial.
MergeTreeData::restorePartFromBackup computes fsync_files once, outside the copy loop, and
passes that same value for every file; BackupImpl::copyFileToDisk branches on sync uniformly
per call. So the failure mode is all-or-nothing and moves the count by 18, far outside the
remaining slack. Disabling fsync_after_insert on the encrypted table does flip that line to 0
and fail the test.

The suggested remedy (a second encrypted table with fsync_after_insert=0 to form a delta) would
add another encrypted disk, another full plus incremental backup pair and a new .reference line,
and would not address the identifier error this PR exists to fix.

Recorded as a residual rather than dismissed: arm 3 is weaker than arm 1 by construction. It is
pre-existing, it is narrowed here, and it is not what makes the 25.8 backport red.

💡 Two nits from my own review, not fixed (noted, not blocking)

  • Arm 1 binds this count as {copied:UInt64} and arm 3 as {files:UInt64}. Both now carry the
    same physical count, so the two names read inconsistently. Renaming grows the diff for no
    behaviour change.
  • The cross-arm reuse rests on a comment stating that the two tables have the same part layout,
    not on a mechanical tie. The equality is measured on both branches (18 = 18 on master, 15 = 15
    on 25.8, file lists byte-identical), and a degenerate count fails loudly: forcing the measured
    path to be unreadable flips has zero-byte part file to 0, and an empty parameter is a hard
    ATTEMPT_TO_READ_AFTER_EOF, which is the second error in the Backport #111378 to 25.8: Fsync restored part files on RESTORE to survive power loss #115088 log.

Session id: cron:clickhouse-review-slot-11:20260817-095700

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Against the official 25.8 binary (25.8.30.20-lts) the old test fails on every run with Code: 47 UNKNOWN_IDENTIFIER on SELECT files FROM system.parts followed by Code: 32 ATTEMPT_TO_READ_AFTER_EOF for the empty {files:UInt64} parameter, matching the #115088 CI log exactly. Live probe on that server: system.columns has 0 rows for parts.files and 1 for parts.path (positive control).
b Root cause explained? Yes. system.parts.files was added by 476e9fc in January, after 25.8 forked. The cherry-pick applies cleanly and the script is byte-identical, so nothing at merge or compile time can see a test-level dependency on a newer column. At runtime the SELECT throws UNKNOWN_IDENTIFIER, the shell variable is left empty, and parameter binding then fails.
c Fix matches root cause? Yes. The dependency is removed, not tolerated: the count now comes from the physical file measurement the test already performs (SELECT path + find). No version guard, no widened bound, no added no-random-* tag.
d Test intent preserved / new tests added? Preserved and strengthened. The assertion still requires the restore to fsync every part file, now against 18 files rather than the 14 the checksums map enumerated, since the physical count also covers checksums.txt, columns.txt and the zero-byte arr.bin. .reference is byte-identical. Test-only change, so no new test is owed.
e Both directions demonstrated? Yes. On 25.8 the old test fails with the two errors above and the new one runs to completion. On master the new test passes 6/6 reference lines, and setting fsync_after_insert = 0 on the encrypted table flips the assertion line to 0 and fails the test.
f Fix is general across code paths? Yes. The first arm was already branch-portable and is untouched; the encrypted arm was the only defect site. The 26.3/26.5/26.6/26.7 backports keep the old line and are green there. The other in-tree readers of the column (04250_packed_skip_indices_mutations.sh, 03791_system_parts_files_column.sql) have no open backport and are out of scope.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes, and this is the load-bearing claim. The cross-arm layout equality was measured on two branches with different layouts, 18 files on master and 15 on 25.8, and holds on both because it follows from identical schema, data and min_bytes_for_wide_part = 0 under no-random-merge-tree-settings, not from any branch-specific file set. 50/50 runs green with randomized settings.
h Backward compatible? (maintainer-approved exception only) N/A, nothing to break. Test-only: no src/ change, no setting, no default, no SettingsChangesHistory.cpp entry, no serialization or on-disk format surface.
i Invariants and contracts preserved? Yes. .reference is byte-identical, so the oracle did not move. The one new coupling, the encrypted arm reusing the first arm's count, is stated in a comment and fails loudly rather than silently: forcing the measured path to be unreadable flips reference line 1 to has zero-byte part file: 0 and fails the test, so a degenerate count cannot pass unnoticed.

Session id: cron:clickhouse-impl-slot-6:20260817-093300

@clickhouse-gh

clickhouse-gh Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fd8fc0c]

Summary: ❌

job_name test_name status info comment
Stress test (amd_msan) FAIL
Hung check failed, possible deadlock found FAIL cidb IGNORED

AI Review

Summary

This PR removes the master-only system.parts.files lookup from 04550_restore_fsync_after_insert.sh and reuses the existing physical file count from the plain restore arm for the encrypted incremental restore assertion. I checked the current diff, the surrounding restore/copy implementation, the existing PR discussion, the failing backport report linked in the description, and the current PR CI, and I did not find a remaining correctness or coverage issue in the updated test oracle.

Final Verdict

✅ No code review findings. The only red CI job on this PR is the unrelated Build profile diff infrastructure failure (KeyError: 'clickhouse/stateless-test').

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 17, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @jkartseva, could you review this? It is a test-only fix: 04550 read the files column of system.parts, which postdates the 25.8 fork and breaks the automated backport, so the encrypted-restore fsync assertion now uses the physical part-file count the test already measures.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Aug 17, 2026
@PedroTadim PedroTadim self-assigned this Aug 17, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing fd8fc0cb5 with master cb425829a (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
Binary Master PR Δ
programs/clickhouse-stripped 700.93 MiB 697.91 MiB -3.01 MiB (-0.43%)

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 units

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

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - fd8fc0c

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.

Check / test Reason Owner / fixing PR
Stress test (amd_msan) / Hung check failed, possible deadlock found not PR-caused: groupConcat over FixedString calls castColumn on the whole block column once per row, so GroupConcatImpl::add is quadratic and the cancelled query (is_cancelled=1, max_execution_time=10) keeps running 526s a fix task is created (investigating at full effort, fixing PR link to follow on this PR)

Notes on the two reds that are not failures:

  • Config Workflow / Pre Hooks FAIL at 10:25:25Z belongs to a superseded run on this same commit.
    The live run at 10:29Z has Pre Hooks OK plus Check Workflows / Check CI DB / docker digests /
    Cache Lookup / Submodule Cache / Init Report all OK.
  • Build profile diff is informational and carries no test rows.

Evidence for the hung check, read from hung_check.log (494 KB) rather than the CIDB context,
which is truncated to the last 32 KiB and does not contain the query text:

  • 4 processlist rows, all Select, all is_cancelled: 1, elapsed 525.9-527.5s against
    max_execution_time = 10, peak memory 143-285 MB (so not an OOM).
  • The 5 working threads are running, not blocked: ConvertImpl<DataTypeFixedString, DataTypeString> -> castColumn -> GroupConcatImpl<false>::add -> addBatchSinglePlace ->
    Aggregator::executeWithoutKeyImpl. The 8 remaining stacks are the system.stack_trace sampler.
  • GroupConcatImpl::add (AggregateFunctionGroupConcat.cpp:87-109) is a per-row callback that
    casts the entire column and then uses a single row of the result.

Reproduced off CI on a master debug build, with controls: FixedString takes 1.38s / 4.88s / 13.27s
at 20k / 40k / 80k rows (super-linear), while the same query over String is flat at 0.17s for all
three, isolating the cast branch. A 3s max_execution_time on 400k FixedString rows overshoots to
12.5s, the same shape as the CI red.

This PR's diff is one shell test file (04550_restore_fsync_after_insert.sh, 7+/7-, zero source
files), and the stuck queries are AST-fuzzer mutations in unrelated databases, so it cannot be the
cause. Breadth of the parent hung-check family: 774 rows across 409 distinct PRs with 69 master
rows in 30 days.

Session id: cron:our-pr-ci-monitor:20260817-150000

@PedroTadim
PedroTadim added this pull request to the merge queue Aug 18, 2026
Merged via the queue into ClickHouse:master with commit 062bb79 Aug 18, 2026
354 of 358 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 18, 2026
@groeneai groeneai added the groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding label Aug 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the Stress test (amd_msan) / Hung check failed, possible deadlock found line on my CI finish ledger above: #116795.

Root cause is what the ledger line recorded: for a FixedString argument groupConcat called castColumn on the whole block column once per row, so a block of B rows performed B whole-column conversions. Reproduced deterministically off CI at 45.3 s for 400,000 rows against 0.11 s for the same query over String, which is why the cancelled query kept running for 526 s against max_execution_time = 10. Issue: #116740.

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 groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding 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