Repository navigation
Fix KeeperMap metadata compatibility with redundant parentheses - #115642
Conversation
Mixed-version servers can serialize equivalent KeeperMap primary key expressions as either key or (key), causing shared metadata validation to reject a compatible table definition. Normalize new metadata and compare parsed canonical primary keys while retaining strict rejection of malformed or genuinely different definitions. Add an integration regression that seeds the legacy Keeper state directly. Local checks: git diff --check; Python byte-compilation; SQL syntax parsing. Full build and integration execution are deferred to CI because this worktree has no initialized submodules or container runtime.
Seed legacy parenthesized Keeper metadata through system.zookeeper, verify canonical writer and strict rejection cases, and remove the Python-only fixture. Also size the compatibility parser to the already-loaded expression instead of the unrelated default query limit. Verified red-before on official 26.7.1.1315 with chctl, git diff checks, and a snapshot-bound Luna Max hostile review. Full green execution remains CI-gated.
|
Workflow [PR], commit [c0b07b3] Summary: ✅
AI ReviewSummaryThis PR teaches patched Findings❌ Blockers
Final Verdict
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 69/85 (81.18%) · Uncovered code |
| { | ||
| const auto canonical_zk_pk = tryCanonicalPrimaryKey(zk_pk); | ||
| const auto canonical_local_pk = tryCanonicalPrimaryKey(local_pk); | ||
| pk_equal = canonical_zk_pk && canonical_local_pk && *canonical_zk_pk == *canonical_local_pk; |
There was a problem hiding this comment.
isMetadataStringEqual only makes the current server tolerant of stored primary key: (key); it never repairs the znode after proving semantic equality. If a buggy/newer replica has already written (key), this branch returns success but leaves Keeper unchanged, so an older reader such as 26.4 still sees the same raw text and rejects the table on the same shared path. To actually restore mixed-version compatibility, this path needs to rewrite zk_metadata_path back to the canonical metadata_string once the canonicalized forms compare equal.
Equivalent primary-key metadata with redundant parentheses was accepted but left unchanged, so older replicas could keep rejecting the shared definition. Normalize only the primary-key suffix through a versioned Keeper CAS, preserve stored column metadata, and retry concurrent changes. Extend the SQL regression to verify the persisted repair.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
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 units9 translation units recompiled, 37 s compile time in total, 9 of them have a recent master baseline. |
Writer-side canonicalization and znode repair make rolling mixed versions unsafe and depend on a formatter unavailable in 26.4. Keep the writer spelling and shared metadata untouched, and normalize only redundant whole-expression parentheses while comparing metadata in CREATE and ATTACH paths. Extend the SQL regression to cover both spelling directions, unchanged stored metadata, ATTACH, malformed and terminated input, and a delimiter inside the expression. Verified with git diff --check, red-before probes on official 26.4.5 and 26.7.1, and snapshot-bound hostile review; green-after remains a CI gate.
|
Addressed by narrowing the changelog and PR contract to patched-reader compatibility. This change intentionally does not rewrite shared Keeper metadata: patched nodes accept both |
Backport #115642 to 26.7: Fix KeeperMap metadata compatibility with redundant parentheses
…edundant parentheses
Backport #115642 to 26.6: Fix KeeperMap metadata compatibility with redundant parentheses
Related: #114188
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Allow KeeperMap readers to accept shared metadata when equivalent primary keys differ only by redundant outer parentheses.
Problem
KeeperMap stores the table definition in Keeper and previously compared its primary-key expression as formatted text. Builds that serialize the same expression as either
keyor(key)therefore reject an otherwise compatible shared table definition during CREATE-against-existing-path and ATTACH/startup.Implementation
This is intentionally a reader-side compatibility fix. A patched node accepts either spelling, but an unpatched node may still reject metadata serialized in the spelling it does not understand. Therefore every version participating in a rolling deployment must contain this fix; in particular, the same reader change must be backported to 26.4. Rewriting the shared znode here would not solve compatibility safely because it could replace the spelling with one rejected by another unpatched peer.
The implementation uses parser and formatter APIs present in both current master and 26.4. It does not depend on
formatIgnoringRedundantParentheses()added by #114188, so the same compatibility rule can be backported to 26.4.Tests
The stateless SQL regression covers both directions (
keystored with(key)local and(key)stored withkeylocal), verifies that compatible CREATE and ATTACH do not rewrite the Keeper znode, and checks data access after ATTACH. It also verifies rejection of a different key, malformed(key, and terminatedkey;metadata, plus a primary-key expression containing the metadata header text.Red-before was reproduced with embedded Keeper on official ClickHouse 26.4.5.143 and 26.7.1.1315: after changing stored metadata from
keyto(key), DETACH + ATTACH left the table inINVALID_STATE(Code 668). Localgit diff --checkand a snapshot-bound hostile review passed. Green-after remains a CI gate for this commit and for the future 26.4 backport.Workflow [PR]
Sync PR [sync-upstream/pr/115642]
Version info
26.8.1.1874(included in26.8and later)26.7.6.6,26.6.4.11