Repository navigation
Conversation
… checksum entries When a replica fetches a part containing a projection that was dropped from the table schema, the sender's `getProjectionParts` does not include the unknown projection, so its `.proj/` subdirectory is not transferred -- but `checksums.txt` is copied verbatim from the sender and still references the orphan entry. `checkDataPart` (called from `CHECK TABLE` and the background `ReplicatedMergeTreePartCheckThread`) then computed `checksums_data` from the actual on-disk files (which do not include the missing `.proj`) and called `checksums_txt.checkEqual(checksums_data, ...)`, which threw `NO_FILE_IN_DATA_PART` for the orphan entry. The background thread caught the exception, marked the part broken, and re-fetched it from the same replica -- producing the same state and looping indefinitely. Strip orphan `.proj` entries from `checksums_txt` whose directory is not on disk before `checkEqual`. This mirrors the existing handling for the local-attach variant (PR ClickHouse#99623) where the directory is on disk but unknown to the table; together they cover both ways an unknown projection can outlive the table schema. Add `tests/queries/0_stateless/04203_100413_check_table_unknown_projection_after_fetch.sh` which exercises the fetch path (`SYSTEM SYNC REPLICA` after dropping the projection) and verifies `CHECK TABLE` succeeds on the receiver. Closes ClickHouse#100413
|
Pre-PR Validation Gate (per task-worker procedure): a) Deterministic repro? ✅ b) Root cause explained? ✅ c) Fix matches root cause? ✅ d) Test intent preserved? / New tests added? ✅ e) Both directions demonstrated? ✅
f) Fix is general, not a narrow patch? ✅ |
|
cc @CheSema @KochetovNicolai — could you review this? Follow-up to #99623: the existing block in |
|
Workflow [PR], commit [acaea9f] Summary: ❌
AI ReviewSummary
Final Verdict
|
|
@groeneai check CI failures. |
…13-orphan-proj-checksum-fetch
|
zlareb1, triaged the 3 failures on Root cause (single): the run's base
PR-relatedness check: this PR's diff is Reapply attempt for #104690 is open as #106386 (mstetsyuk) and is what should fix the upstream bug; not in our path. Action: rebasing the branch onto current master (post-revert) and pushing. No other code change needed for these failures. Will report back if anything reappears on the new SHA. session: cron:clickhouse-ci-task-worker:20260607-082800 |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 11/11 (100.00%) | Lost baseline coverage: none · Uncovered code |
|
CI Ledger — covered SHA: CI finished. Both failures classified and already tracked elsewhere; neither is caused by this PR's diff (
This PR's diff does not touch sorting, merging, or function-prop-fuzzer surfaces. |
|
Closing: superseded by #108118 (merged 2026-07-22), which landed the same fix in Master now drops leftover The re-fetch loop from #100413 is fixed on master, so there is nothing left for this PR to add. |
Problem
When a replica fetches a part containing a projection that was dropped
from the table schema, the sender's
getProjectionPartsdoes notinclude the unknown projection, so its
.proj/subdirectory is nottransferred -- but
checksums.txtis copied verbatim from the senderand still references the orphan entry.
checkDataPart(called fromCHECK TABLEand the backgroundReplicatedMergeTreePartCheckThread) then computedchecksums_datafrom the actual on-disk files (which do not include the missing
.proj) and calledchecksums_txt.checkEqual(checksums_data, ...),which threw
NO_FILE_IN_DATA_PARTfor the orphan entry.The background thread caught the exception, marked the part broken,
and re-fetched it from the same replica -- producing the same state
and looping indefinitely.
Fix
Strip orphan
.projentries fromchecksums_txtwhose directory isnot on disk before
checkEqual, insrc/Storages/MergeTree/checkDataPart.cpp.This mirrors the existing handling for the local-attach variant
(PR #99623) where the directory is on disk but unknown to the table;
together they cover both ways an unknown projection can outlive the
table schema:
checksums.txtentryDETACH+ drop projection +ATTACH)SYSTEM SYNC REPLICA)In both cases
is_broken_projectionis set so the caller can reactgracefully.
Test
Added
tests/queries/0_stateless/04203_100413_check_table_unknown_projection_after_fetch.shwhich:
ReplicatedMergeTree,ppon replica 1,ppfrom the table schema, dropsreplica 2's detached copy,
pp.proj/on disk, orphanpp.projentry inchecksums.txt),SYSTEM SYNC REPLICAon replica 2 -- forces a fetch where the.proj/subdirectory is not transferred butchecksums.txtis,CHECK TABLEon replica 2 withcheck_query_single_value_result = 1.Pre-fix, step 6 returned
0and the server log showedPart 0_5_5_0 looks broken. Removing it and will try to fetch.(the start of there-fetch loop). Post-fix it returns
1.Verified locally: 20/20 passes with random settings. Existing tests
03822_attach_with_unknown_projectionand03145_non_loaded_projection_backupare unaffected.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed an infinite re-fetch loop when a
ReplicatedMergeTreereplica fetches a part that contains a projection unknown to the current table schema (e.g. the projection was dropped while the part was detached on the sender). Previously, the sender skipped the unknown.proj/subdirectory but copiedchecksums.txtverbatim -- the receiver'scheckDataPartthen threwNO_FILE_IN_DATA_PART, marked the part broken, and re-fetched it forever.checkDataPartnow strips orphan.projentries fromchecksums_txtwhose directory is not on disk, mirroring the existing handling for the local-attach variant.Documentation entry for user-facing changes
Closes #100413
Session: cron:clickhouse-ci-task-worker:20260505-111500