Skip to content

redo Part with unknown projections should not be marked as lost forever - #99623

Merged
alexey-milovidov merged 14 commits into
masterfrom
chesema-redo-95952
Mar 20, 2026
Merged

alexey-milovidov merged 14 commits into
masterfrom
chesema-redo-95952

Conversation

@CheSema

@CheSema CheSema commented Mar 16, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Redo #95952

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

Part with unknown projections should not be marked as lost forever

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.73

@CLAassistant

CLAassistant commented Mar 16, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ alexey-milovidov
✅ CheSema
❌ Semen Checherinda


Semen Checherinda seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@clickhouse-gh

clickhouse-gh Bot commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [16050a4]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Mar 16, 2026
…rojections

After handling unknown projections, clear projections_on_disk so the
throw_on_broken_projection block does not re-throw for already-handled
entries. This fixes CHECK TABLE returning failure for parts with unknown
projections.

Suppress expected warnings in the test only for CHECK TABLE and OPTIMIZE
commands that read parts with unknown projection directories.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@CheSema CheSema changed the title redo 95952 redo Part with unknown projections should not be marked as lost forever Mar 16, 2026
# knows about projection pp.
run "ALTER TABLE t_unknown_proj_1 ATTACH PARTITION 0"

# The part must be usable: CHECK TABLE should pass and data should be intact.

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.

The comment says CHECK TABLE should pass, but the assertion right below expects Found unexpected projection directories: pp.proj in stderr.

Could you reword this to match actual behavior (for example: "CHECK TABLE should report unknown projection directories, while the part remains readable")? The current wording is misleading during future triage.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The warning message is expected, but the check should pass.

@CheSema

CheSema commented Mar 17, 2026

Copy link
Copy Markdown
Member Author

03822_attach_with_unknown_projection is not stable due to missing synchronization betweenMATERIALIZE PROJECTION and DETACH PARTITION, fixing it

CheSema and others added 2 commits March 18, 2026 11:47
`sendPartFromDisk` already patches `data_checksums` for unknown `.proj`
entries so the sender-side `checkEqual` passes, but the receiver in
`downloadPartToDisk` was not doing the same. When `checksums.txt`
contains `.proj` entries that were not transferred (projection dropped
while part was detached), the receiver-side `checkEqual` would fail.

Copy unknown `.proj` entries from `checksums.txt` into `data_checksums`
before the check, mirroring the sender-side logic.

Add test coverage: sync replica 2 and verify it successfully fetches
the part with unknown projection from replica 1 on a local disk.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@Michicosun Michicosun self-assigned this Mar 18, 2026
@clickhouse-gh

clickhouse-gh Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 83.70% 83.80% +0.10%
Functions 24.00% 24.00% +0.00%
Branches 76.30% 76.40% +0.10%

PR changed lines: PR changed-lines coverage: 97.44% (38/39, 0 noise lines excluded)
Diff coverage report
Uncovered code

@alexey-milovidov
alexey-milovidov merged commit 8b25daa into master Mar 20, 2026
159 checks passed
@alexey-milovidov
alexey-milovidov deleted the chesema-redo-95952 branch March 20, 2026 23:43
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 21, 2026
@zlareb1

zlareb1 commented Mar 23, 2026

Copy link
Copy Markdown
Member

@CheSema Please check #100413

zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request Mar 23, 2026
… with unknown projections

PR ClickHouse#99623 fixed the receiver-side `downloadPartToDisk` so the immediate
`checkEqual` passes after fetching a part whose `checksums.txt` references a
projection that is no longer in the table metadata.  However, any subsequent
call to `checkDataPart` (from `CHECK TABLE` or `ReplicatedMergeTreePartCheckThread`)
still fails with `NO_FILE_IN_DATA_PART`, because:

- `projections_on_disk` is built by iterating the part directory for `.proj`
  subdirectories — the directory was never transferred, so it stays empty.
- The guard added by ClickHouse#99623 (`if (!projections_on_disk.empty())`) does not fire.
- `checksums_txt` (loaded from the on-disk `checksums.txt` written verbatim
  from the sender) still contains the `pp.proj` entry.
- `checksums_data` does not contain `pp.proj` (directory was never on disk).
- `checksums_txt.checkEqual(checksums_data)` throws `NO_FILE_IN_DATA_PART`.

The part is then marked broken, re-fetched from replica 1, and the cycle repeats.

**Fix:** after the existing block that removes unknown projection directories
present on disk from `checksums_txt`, add a complementary pass that removes
any remaining `.proj` entries in `checksums_txt` whose key is absent from
`checksums_data`.  This covers the fetch case where the directory was never
on disk at all.

**Test:** extend `03822_attach_with_unknown_projection.sh` to run
`CHECK TABLE t_unknown_proj_2` after `SYSTEM SYNC REPLICA t_unknown_proj_2`,
explicitly covering the code path that was broken.

Fixes: ClickHouse#100413
Related: ClickHouse#99623

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
CheSema added a commit that referenced this pull request Mar 23, 2026
Cherry-picked from ClickHouse/ClickHouse master (PR #99623).
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default 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.

6 participants