Repository navigation
Conversation
|
Workflow [PR], commit [2856348] Summary: ❌
AI ReviewSummaryThis PR adds the experimental ❌ Blockers
|
| Metric | Baseline | Current | Δ |
|---|---|---|---|
| Lines | 88.20% | 88.20% | +0.00% |
| Functions | 91.70% | 91.70% | +0.00% |
| Branches | 79.50% | 79.50% | +0.00% |
Changed lines: Changed C/C++ lines covered: 1246/1337 (93.19%) · Uncovered code
2b33155 to
48820b8
Compare
|
Interesting idea! I can't read the private repo issue that this refers to, but I'm curious to learn what the advantages and disadvantages of the flat format are? |
48820b8 to
79593ba
Compare
79593ba to
147250e
Compare
720b5c8 to
ff85e88
Compare
|
Updating the branch to fix the |
e7c6bc9 to
298de31
Compare
7ffc147 to
653a7bb
Compare
653a7bb to
5f6489f
Compare
ac820bd to
e8f1a7a
Compare
# Conflicts: # src/Storages/MergeTree/MutateTask.cpp
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes68 object files changed (+419.30 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units1942 translation units recompiled, 11727 s compile time in total, 1942 of them have a recent master baseline. |
…t projection siblings Two lifecycle gaps of the FLAT projection layout: 1. With \`fsync_part_directory = 1\`, \`freeze\` on the local hardlink path only synced \`<to>/<part>\` and its ancestors, while the copied FLAT siblings live beside it as \`<to>/<part>.<name>.proj\` -- a crash after \`FREEZE\` could persist the shadow parent (whose \`checksums.txt\` references the projection) while losing a sibling dentry. The packed override inherited the same hole because it disables the child fsync and relies on the top-level sync. \`fsyncFrozenCloneTree\` now takes the copied sibling trees and syncs them before the shared ancestor chain walk; both \`freeze\` overrides pass them via the new \`frozenFlatSiblingClonePaths\` helper. 2. The stale-sibling sweep at rename destinations was gated on the moving part's own \`flat_projection_storage_in_use\` flag, seeded from the current table setting. After \`ALTER TABLE ... MODIFY SETTING projection_storage_format = 'legacy_nested'\`, a new nested part reusing the final name of an interrupted pre-switch flat publish no longer swept the leftover \`<part>.<name>.proj\`; once the parent went live the sibling was no longer orphaned, so \`clearOrphanProjectionSiblings\` never reaped it. \`MergeTreeData\` now keeps a monotonic per-process \`flat_projection_storage_ever_used\` latch (raised at the \`getProjectionStorageFormat\` choke point and when a loaded/adopted part owns FLAT projections) and the per-part flag is seeded from it, so the sweep stays enabled after a downgrade. Residue that outlives a restart is parentless and already reaped by the startup orphan GC. Tests: \`test_residue_swept_after_downgrade\`, \`test_residue_swept_after_downgrade_and_restart\` (pins the load-time latch), \`test_fsync_freeze_copies_sibling\`. Co-Authored-By: Claude Fable 5 <[email protected]>
The style check requires new MergeTree settings to be recorded in the current version block. The entry was added under 26.8, which has since been closed by the 26.9 release cycle on master, so move it to 26.9. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108443&sha=94834c7b2914f540daa30b6ad6a45b023274cfca&name_0=PR&name_1=Style%20check PR: #108443 Co-Authored-By: Claude Fable 5 <[email protected]>
…-storage-format # Conflicts: # src/Storages/MergeTree/MergeTreeData.cpp # src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.cpp # src/Storages/MergeTree/checkDataPart.cpp # src/Storages/StorageMergeTree.cpp
…gh `StorageMergeTree::checkDataNext` The repair branch of `CHECK TABLE` (the one taken when a live part's `checksums.txt` is gone) threw away everything `checkDataPart` returns except the parent's recomputed checksums: it compared them against the stale in-memory `part->checksums`, wrote that stale manifest back to disk, and ignored the regenerated child projection manifests. A part re-attached after `DROP PROJECTION` still lists the dropped projection in its in-memory manifest, so the intact part was reported broken (`No file p.proj in data part`), and a projection whose own `checksums.txt` was also missing never got it back. Mirror `IMergeTreeDataPart::loadChecksums`: compare against the in-memory manifest minus the `.proj` entries `checkDataPart` normalized away, persist `computed_projections_checksums` for the children, then write `computed_checksums` as the parent manifest. `checkDataPart` now also reports the recomputed checksums of a *loaded* projection whose manifest is missing, so the live-part repair covers that case. `test_reload_check_table_dropped_projection` is updated to master's semantics (51e9f05): a since-dropped projection listed in the part's own manifest keeps the part passing `CHECK TABLE`. Two new cases pin the repair branch: `test_reload_check_table_dropped_projection_missing_manifest` and `test_recovery_check_table_recompute_missing_projection_checksums`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
| { | ||
| auto calculated_checksums = checkDataPart(part, false, noop, /* is_cancelled */[]{ return false; }, /* throw_on_broken_projection */true); | ||
| calculated_checksums.checkEqual(part->checksums, true, part->name); | ||
| auto result = checkDataPart(part, false, noop, /* is_cancelled */[]{ return false; }, /* throw_on_broken_projection */true); |
There was a problem hiding this comment.
The same empty-result contract is still missed here. The public checkDataPart wrapper returns {} when verification was skipped because of a retryable error, but this CHECK TABLE repair path immediately runs checkEqual on result.computed_checksums.
So a transient verification failure is reclassified as UNEXPECTED_FILE_IN_DATA_PART / NO_FILE_IN_DATA_PART, and CHECK TABLE reports a healthy part as corrupt instead of retrying. Please bail out on result.computed_checksums.empty() before checkEqual and let the retryable path retry, the same way the packed-fetch verification does.
There was a problem hiding this comment.
🕵 Fixed in f7b314f: both IMergeTreeDataPart::loadChecksums and StorageMergeTree::checkDataNext now check result.computed_checksums.empty() right after checkDataPart and throw a retryable ABORTED (same contract as the packed-fetch verification in DataPartsExchange). Nothing is written back, the part is not marked broken at load (loadDataPart rethrows retryable errors), and CHECK TABLE rethrows instead of reporting a mismatch.
There was a problem hiding this comment.
This is still open in the checksums-present branch. StorageMergeTree::checkDataNext now checks result.computed_checksums.empty() only in the missing-manifest arm, but the normal arm at src/Storages/StorageMergeTree.cpp:3972 still calls checkDataPart(...) for side effects and drops the CheckDataPartResult entirely. The public wrapper still returns {} on retryable verification failures at src/Storages/MergeTree/checkDataPart.cpp:634, so that branch still reports success instead of retrying whenever verification was skipped because of a transient error.
…-storage-format Resolved conflicts: - `StorageMergeTree::startup`: master now skips temporary-directory cleanup for read-only tables; kept `clearOrphanProjectionSiblings(0)` inside the same non-read-only block. - `IMergeTreeDataPart::getProjectionPartBuilder`: kept the PR's read-only builder. Master's new `PartDirIntent::Synthetic` caller in `WhatIfProjectionEstimator` now uses a dedicated `getSyntheticProjectionPartBuilder`, which never creates or reclaims the directory. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ult` of a skipped recount The public `checkDataPart` wrapper returns an empty result when verification was skipped because of a retryable error. `IMergeTreeDataPart::loadChecksums` wrote that as an empty `checksums.txt` (dropping every `.proj` ownership entry), and `StorageMergeTree::checkDataNext` reported a healthy part as corrupt. Both now throw a retryable `ABORTED`, like the packed-fetch verification in `DataPartsExchange`, so the part is not marked broken and the operation is retried. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…history block The `settings_changes_history` style check requires the new setting under the current version. The setting has not shipped in a release, so the record is moved rather than duplicated. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
|
||
| /// Zero-copy replication may share blobs across replicas invisibly to the local refcount. | ||
| bool keep_shared = false; | ||
| if (disk->supportZeroCopyReplication() && (*getSettings())[MergeTreeSetting::allow_remote_fs_zero_copy_replication]) |
There was a problem hiding this comment.
keep_shared is keyed off the current allow_remote_fs_zero_copy_replication value here, but the table can still have shared remote blobs after that setting was turned off again. The same file already relies on that invariant in swapActivePart (MergeTreeData.cpp:8704): a replica may still need to keep shared data even when the setting is now 0.
That makes this new cleanup path unsafe for historical zero-copy state. A replicated object-storage table can leave an orphan *.proj sibling while zero-copy is enabled, disable the setting later, and then have startup/background GC hard-delete blobs that another replica still references. Please make orphan/residue projection cleanup fail-safe on zero-copy-capable disks as well, instead of deciding from the current setting.
|
|
||
| Both layouts are always read transparently; the setting only controls the layout of newly written parts. It applies to both full and packed part storage (a packed projection sub-part keeps its own `data.packed` archive in either layout). | ||
|
|
||
| Downgrade note: a server version without `flat` support loads a `flat` part with its projections marked broken (queries fall back to reading the parent part; projections can be rebuilt with `ALTER TABLE ... MATERIALIZE PROJECTION`), and it never removes the sibling directories, so they remain on disk until a version with `flat` support cleans them up. To downgrade cleanly, set `projection_storage_format = 'legacy_nested'` and rewrite `flat` parts first (for example with `OPTIMIZE TABLE ... FINAL`). |
There was a problem hiding this comment.
This downgrade note overpromises. projection_storage_format is persisted as a normal MergeTree table setting, and older binaries still reject unknown MergeTree settings while loading table metadata (MergeTreeSettingsImpl::loadFromQuery still applies the stored settings list). So after MODIFY SETTING projection_storage_format = 'legacy_nested' and rewriting the old flat parts, the table still does not load on a server that predates this setting until the setting is removed from metadata as well (for example ALTER TABLE ... RESET SETTING projection_storage_format).
Please document that metadata-cleanup step, otherwise the advertised rollback path fails before the older server can even get to the “mark projections broken” behavior described here.
| } | ||
| } | ||
|
|
||
| part_mutable.writeChecksums(result.computed_checksums, write_settings); |
There was a problem hiding this comment.
writeChecksums only repairs the files on disk; it does not install the repaired manifests back into the live part objects. After this branch returns, part->checksums and any already-loaded projection-part checksums still hold the pre-repair state until restart.
That leaks into send/backup paths that read the in-memory manifests. For example, DataPartsExchange::sendPartFromDisk iterates part->checksums, so a stale dropped *.proj entry (or a projection whose own checksums.txt was repaired here) can still be re-advertised even though the on-disk manifests were fixed. Please update the live IMergeTreeDataPart / loaded projection parts in memory after writing the repaired manifests, not just the files on disk.
|
|
||
| # merge into a single part; the merged part rebuilds the projection | ||
| node.query("SYSTEM START MERGES t_os_merge") | ||
| node.query("OPTIMIZE TABLE t_os_merge FINAL") |
There was a problem hiding this comment.
This only proves the merged part works before it is reopened. The object-storage failure mode this PR is fixing is about part metadata / transaction state that can look fine immediately after OPTIMIZE TABLE ... FINAL and only break once the merged part is loaded back from disk.
The local-disk merge coverage above does a restart, but the dedicated object-storage merge test stops here, so a broken reopen path on s3 would still ship green. Please restart the server (or otherwise force the merged part to be reopened) before the final proj_query / CHECK TABLE assertions.
New projection storage format - FLAT, when a projection lives in a directory neighbouring to the data part's directory, in opposite to the original storage format, now called LEGACY_NESTED, when a projections lives in a directory nested to the data part. Example:
part dir = all_1_1_0, projection p
LEGACY_NESTED (default) -> store/uuid/all_1_1_0/p.proj
FLAT -> store/uuid/all_1_1_0.p.proj
The projection storage format is controlled via
projection_storage_formatengine setting (EXPERIMENTAL), and therefore it is table specific. It defines the format for the new parts to be created, so enabling FLAT for an existing table, doesn't modify its parts, but every upcoming inserts mutation, merge or materialization operation will force it for new parts. Both layouts are always supported on read operations; the setting only defines layout for newly-written parts.FLAT is designed for engines with atomic multi-directory commit. The atomicity for MergeTree on local disks, is ensured via the order of operations: when parts are going live, main data part always goes last - in case of mid-failures, the FLAT sibling projections will be handled as orphans; when part are going off-live, main data part always goes first - preventing FLAT projections to be used since then.
Major changes
Other issues fixed
Improvements
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
New experimental feature, to set projection storage format with
projection_storage_formatto one of: 'legacy_nested' (current and default), 'flat'. FLAT stores projections in a separate directory in the same root directory as the main data part.Workflow [PR]
Sync PR [sync-upstream/pr/108443]