Repository navigation
Do not regenerate part names from part infos for tables with the deprecated syntax - #114980
Conversation
…ecated syntax
A table created with the deprecated positional syntax
(ENGINE = ReplicatedMergeTree(date, key, granularity) under
allow_deprecated_syntax_for_merge_tree) uses date-based V0 part names.
MergeTreePartInfo::getPartNameAndCheckFormat cannot produce such a name,
because getPartNameV0 needs the min/max DayNum that MergeTreePartInfo does
not carry, so it throws BAD_DATA_PART_NAME unconditionally.
Two ActiveDataPartSet entry points accept only a MergeTreePartInfo and must
therefore synthesize a name that way: tryAddPart and add(info, Strings *).
Each had exactly one production caller, and both callers already held the
part name and discarded it:
* ReplicatedMergeTreeQueue::getPartNamesToMutate builds mutation.parts_to_do.
The throw aborted mutationsUpdatingTask and left parts_to_do empty, so the
mutation was reported as done on a replica that had not applied it. With
mutations_sync = 2 the ALTER returned success while that replica still
served pre-mutation values. Regressed by ClickHouse#87206, which changed
QueueEntryRepresentation::produced_parts from a vector of names to a vector
of infos.
* StorageReplicatedMergeTree::checkPartsImpl builds the set of empty
unexpected parts on disk. The throw aborted ReplicatedMergeTreeAttachThread
and left the table readonly. Regressed by ClickHouse#103537, which replaced
tryAdd(name, &reason) with add(info, name, ...).
Both failures appear in a single Upgrade check report on ClickHouse#112457. Pass the
name that is already in hand at both call sites instead. V0 name formatting is
untouched, and behaviour on current-format tables is provably unchanged
because the name-taking overload re-parses the name into the identical info
and runs the same addImpl. This is the remedy alexey-milovidov used in
536b611 for the ATTACH PARTITION instance of
the same defect, which added ActiveDataPartSet::tryAdd(const String &).
dropped_parts is deliberately left holding infos only:
removePartAndCoveredParts(info) is getPartsCoveredBy + remove, neither of
which regenerates a name.
The V0 gap in MergeTreeData::restorePartFromBackup that the comment at the
throw site describes is a different code path, absent from both stacks here,
and is not addressed.
Testing: 04907_mutation_parts_to_do_deprecated_syntax asserts parts_to_do on
the frozen replica and fails on master with "parts to do 0". checkPartsImpl's
state requires fabricating parts on disk, which is not allowed in a stateless
test, so that half is covered by three V0 cases in gtest_active_data_part_set,
all of which fail with this change reverted.
Internal second-model review (1 finding, resolved)An independent model reviewed this diff cold against the frozen PR body. One finding, adjudicated
Only
The test's entire wall clock is 0.83 - 1.34 s across 50 runs. Feeding The suggested remedy would also be wrong here. The cited precedent pins a non-replicated 💡 Noted, not blocking
|
Pre-PR validation gate
|
|
Workflow [PR], commit [7df7ccd] Summary: ✅
AI ReviewSummaryThis PR fixes the two production paths that were still trying to reconstruct V0 part names from Final Verdict
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 47/52 (90.38%) · Uncovered code |
|
cc @alesapin @Michicosun, could you review this? Two |
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 units8 translation units recompiled, 55 s compile time in total, 8 of them have a recent master baseline. |
…iming The setup-sanity line counted every entry in r2's replication queue. r2 can still hold an unprocessed GET_PART entry for its own part at that point: the entry is normally consumed by the "part already exists" fast path in StorageReplicatedMergeTree::executeLogEntry, but SYSTEM STOP FETCHES makes canExecuteFetch postpone it first, so it stays queued. The count is then 2 rather than 1. Reproduced by delaying r2's queue processing until after the second INSERT; under TSAN the same interleaving happens on its own, which failed the flaky check 4 times in 50 runs while amd_asan_ubsan, amd_msan, amd_debug and amd_binary stayed green. Counting only GET_PART entries for parts r2 does not already have is stable in both interleavings and still reddens when no entry is pending at all, which keeps the precondition meaningful: with an empty queue both parts reach parts_to_do through the name-based path and the assertion under test would pass without exercising the fix. The four assertions the test exists for are untouched and were unchanged in every failing run.
CI finish ledger - 7df7ccdCI is fully finished on this head and there are no failures to own: 177 check runs completed,
The Session id: cron:our-pr-ci-monitor:20260816-123000 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
BAD_DATA_PART_NAME("Trying to get part name in new format for old format version") on aReplicatedMergeTreecreated with the deprecated positional syntax underallow_deprecated_syntax_for_merge_tree. A mutation could be reported as done on a replica that had not applied it, and the table could stay readonly after a restart.Description
Reported by @ alexey-milovidov on #112457 (
Upgrade check (amd_release)report). No related open issue found.A table created with
ENGINE = ReplicatedMergeTree(date, key, granularity)uses date-based (V0) part names.MergeTreePartInfo::getPartNameAndCheckFormatcannot produce one, because the min/max dates it needs are not part of aMergeTreePartInfo, so it throws. TwoActiveDataPartSetentry points take only an info and regenerate the name that way; each had exactly one caller, and both callers already held the name and threw it away. This change passes the name at both call sites, as in536b611c96a757e, which fixed theATTACH PARTITIONinstance of this bug. V0 name formatting is untouched, and current-format tables are unaffected because the name-taking overload re-parses to the same info and runs the same insertion code.The linked report contains both failures:
ReplicatedMergeTreeQueue::getPartNamesToMutatebuildsmutation.parts_to_do. The throw left it empty, so a mutation reportedis_doneon a replica that never mutated its part, andmutations_sync = 2returned success while that replica still served pre-mutation values. Regressed by Improve updating mutations #87206, which changedproduced_partsto hold infos instead of names.StorageReplicatedMergeTree::checkPartsImplbuilds the set of empty unexpected parts. The throw abortedReplicatedMergeTreeAttachThread, leaving the table readonly. Regressed by my own FixLOGICAL_ERROR"Part X intersects previous part Y" during ReplicatedMergeTree startup #103537, which replaced a name-based call with an info-based one.The V0 gap in
MergeTreeData::restorePartFromBackupthat the throw-site comment describes is a different code path, absent from both stacks, and is not addressed.A new stateless test asserts
parts_to_doon the frozen replica: it fails on master (parts to do 0) and passes here (parts to do 2), and 50/50 randomized runs pass.checkPartsImpl's state needs parts fabricated on disk, so that half is covered by three V0 cases added togtest_active_data_part_set.cpp, all of which fail with this change reverted.00062_replicated_merge_tree_alter_zookeeper_longand00652_replicated_mutations_zookeeperstill pass.