Repository navigation
Read and checksum the UNIQUE KEY dense-index SST through IDataPartStorage - #114777
Conversation
|
Workflow [PR], commit [0f427e1] Summary: ❌
AI ReviewSummaryThe PR moves the PR Metadata
Exact replacement: Findings❌ Blockers
Tests
Final VerdictChanges requested. LLVM Coverage ReportMeasured on commit 0f427e1.
Changed lines: Changed C/C++ lines covered: 359/397 (90.43%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes10 object files changed (+59.48 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 units14 translation units recompiled, 98 s compile time in total, 14 of them have a recent master baseline. |
600ab79 to
7f82272
Compare
e5831c2 to
4d05663
Compare
06d9f77 to
6b0a832
Compare
optimize table fix test cases remove useless test cases optimize code optimize test cases
c2b37da to
e10a674
Compare
d8d2f99
|
@JingYanchao @murphy-4o — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
…e local-only gate Follow-up to the link index in the previous commit, which is already pushed and untouched here. ## A bitmap naming a target nobody can parse no longer loads `loadPart` logged and skipped such a file, so its kills left the index and the rows they mark came back on the next restart. It throws CORRUPTED_DATA now and the part is detached. CORRUPTED_DATA and not LOGICAL_ERROR: the latter aborts under debug and sanitizer builds, which would stop the caller ever reaching the detach and would put the test behind `#ifndef DEBUG_OR_SANITIZER_BUILD` like the two beside it. The call sits above `setState`, with the other two `mark_broken` paths of that function: `loadDataPartsFromDisk` promotes a broken part's covered children only while it does not read as Active. Review caught a first attempt that sat below it, where a part broken by the bitmap load was detached and its replacements never loaded. The duplicate-part path leaves its links registered. The index is keyed by part info, which a duplicate shares with the part already there, so `dropPart` would erase the live part's links -- the same lost-kills failure this change closes. Review caught that too, in a first attempt that tried to clean up after itself. ## The local-only storage restriction is gone It was an interim guard held while the dense-index SST read still opened a local filesystem path. That port landed upstream as ClickHouse#114777, which is in this branch's master base, so every SST open in `UniqueKey/` goes through `openSSTReaderFromStorage`, the bitmap file ops take an `IDataPartStorage`, and no local-path primitive is left in the directory. Keeping it also failed two of this module's own integration tests against the configuration they exist to cover: `test_unique_key_sst_roundtrip_on_s3` and `test_unique_key_on_s3_survives_restart` were red with SUPPORT_IS_DISABLED, and both pass with it removed. ## Two tests the index change left uncovered `AStagedVersionResolvesIntoTheMiddleOfTheOrder` straddles a staged link with carried 3, 7 and 12 so the re-key lands between existing entries, which a two-entry case cannot reach. `AStagedLinkIsSweptOnceItsVersionResolves` pins the ordering inside `removeObsoleteBitmaps`: it asks `versionAt` for the floor first, which resolves the link, so a staged version below the floor is swept like any other rather than surviving at the top. Written expecting the opposite; the code was right, and nothing is lost because the surviving floor subsumes it. A third, two staged holders of one target, is not here: both resolve to the same prehistoric csn, so only one can win a read and "both links present" has no observable consequence. It passed with the dedup deliberately broken. ## Verification Build clean, 132/132 UNIQUE KEY gtests, 9/9 `unique_key` stateless, 5/5 `test_unique_key_sst` integration, `check_cpp.sh` silent. Oracles run: appending instead of inserting in order fails `AStagedVersionResolvesIntoTheMiddleOfTheOrder`; resolving nothing fails `AStagedLinkIsSweptOnceItsVersionResolves`; restoring the log-and-skip fails `ABitmapNamingAnUnparseableTargetRefusesTheLoad`. The detach is checked end to end: plant `delete_bitmap_for_not_a_part_name.rbm`, DETACH, ATTACH -> 0 active parts, 1 detached `broken-on-start`, 0 rows readable. Known, and not from this change: UNIQUE KEY INSERT on `metadata_type = plain_rewritable` aborts at `IMergeTreeDataPart::assertHasVersionMetadata` -- the part reaches the transaction commit before its version metadata is visible. Object storage with the default metadata type dedups, deletes and merges correctly. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Part of #103486
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Allow the UNIQUE KEY to work on encrypted and remote disks by reading and writing its dense-index SST through the part storage abstraction; the SST is now recorded in
checksums.txt.Description
The per-part UNIQUE KEY dense index (
unique_key_index.sst) was opened and written by local filesystem path, which only worked on local disks and left the sidecar outside the part's checksum accounting.This PR drives the SST through
IDataPartStorageusing a custom RocksDBEnv(a read-onlyFileSystemoverIDataPartStorage::readFilefor the reader, aWriteBuffer-backed one for the writer), so encrypted and remote disks work as well. The SST is now recorded inchecksums.txt, so it is transferred by backup/fetch like any other part file and validated bycheckConsistencyBase: a missing or wrongly-sized SST fails the standard consistency check and the part is detached as broken, while size-preserving corruption is caught at load time byensureValidDenseIndex(RocksDB block-checksum + entry-count validation), which removes and rebuilds the index. On readonly storage a corrupt or absent SST fails the load closed instead of activating an unprobeable part.The previous restriction that UNIQUE KEY tables must reside on local-only storage policies is removed.
Workflow [PR]
Sync PR [sync-upstream/pr/114777]
Version info
26.9.1.1106(included in26.9and later)