Repository navigation
Do not copy the source part's txn_version files into a mutated part - #127074
alexey-milovidov merged 3 commits into
Conversation
Two pauseable failpoints make the race deterministic: `version_metadata_store_pause_before_rename` stops `VersionMetadataOnDisk::storeInfoToDataPartStorage` after `txn_version.txt.tmp` is written and before it replaces `txn_version.txt` (the same name and spot as in open PR ClickHouse#124485), and `mt_mutate_task_pause_before_rename_part` stops a plain MergeTree mutation after its disk transaction is committed and before the new part is renamed into the table. The test stamps a part's creation CSN with COMMIT paused at the first point, runs a non-transactional mutation over the part while `txn_version.txt.tmp` exists, then reloads the table and checks that the mutated part is kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`MutateSomePartColumnsTask` hardlinks every file of the source part that is not in `collectFilesToSkip`. That set took `txn_version.txt` from `getFileNamesWithoutChecksums`, which lists it only if it exists at that moment, and never contained `txn_version.txt.tmp`. When the source part's version metadata is rewritten concurrently (a commit stamping its creation CSN, e.g. a background merge transaction finalized by the TransactionLog updating thread), `VersionMetadataOnDisk::storeInfoToDataPartStorage` writes `txn_version.txt.tmp` and then renames it over `txn_version.txt`, and the mutation copies the transient file: - on a local disk the mutated part keeps a `.tmp` with the source part's version info and no `txn_version.txt`, so on the next load `VersionMetadataOnDisk::loadMetadata` treats it as rolled back and the part's rows disappear (the source part is already removed); - on object storage the hardlink is deferred to the disk transaction commit, and if the rename happened first the mutation fails with `Can't create hardlink for file .../txn_version.txt.tmp (FILE_DOESNT_EXIST)`. The new part always writes its own version metadata, so skip both files by name. ClickHouse#108772 made the consumers tolerate a stray `.tmp`; this closes the producer. This is the failure of `03752_attach_as_replicated_transaction_metadata` on `Stateless tests (amd_debug, distributed plan, s3 storage, parallel)`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings), plus my own cold review of the diff.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261021-000000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261020-222200 |
|
cc @Algunenano @CurtizJ, could you review this and add the |
|
Workflow [PR], commit [8a7b6d2] Summary: ✅
AI ReviewSummaryThe PR prevents partial-column Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
In the AsyncInsert CI profile (async_insert = 1 in the default user profile) the INSERT inside the transaction is rejected with NOT_IMPLEMENTED (async inserts inside transactions are not supported), so the transaction holds no part, COMMIT never writes version metadata and SYSTEM WAIT FAILPOINT version_metadata_store_pause_before_rename waits until the test timeout. Same pinning as 04408, 05161, 05175 and 05385. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units10 translation units recompiled, 45 s compile time in total, 10 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.07 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
Related: #108772
Related: #124485
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Experimental transactions: a mutation that runs while a part's transaction metadata is being updated no longer copies the part's
txn_version.txt.tmp, so it neither fails withFILE_DOESNT_EXISTon object storage nor produces a part that is dropped as rolled back on the next table load.Description
A mutation that rewrites some columns of a Wide part hardlinks every other file of the source part.
collectFilesToSkipexcludedtxn_version.txtonly if it existed, and never excludedtxn_version.txt.tmp, whichVersionMetadataOnDisk::storeInfoToDataPartStoragewrites and then renames overtxn_version.txtwhen a commit stamps the part's CSN. A mutation that lists the part inside that window copies the temporary file:.tmpwith the source part's version info, so it is loaded as an uncommitted transaction and dropped on the next load, and its rows are lost;Can't create hardlink for file .../txn_version.txt.tmp (FILE_DOESNT_EXIST).The mutated part writes its own version metadata, so both files are now skipped by name. #108772 made the readers tolerate a stray
.tmp; this stops the mutation from producing one.This is the flaky
03752_attach_as_replicated_transaction_metadata, 6 times since June, twice on master: theFILE_DOESNT_EXISTvariant (latest) and on master the lost-rows variant (report,count()1271 instead of 0).The new test uses two pauseable failpoints to stop
COMMITbefore the rename and the mutation before it adds its part. Without the fix it fails on every run on local and on encrypted S3 storage; with it, 50/50 randomized runs pass on each.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127074]
Version info
26.11.1.582-master(included in26.11and later)