Repository navigation
Conversation
…irectory `table_disk = 1` leaves `relative_data_path` empty, so a MergeTree table's data directory is the root of its disk. A readonly table over the same plain_rewritable endpoint therefore shares one directory with the live table that writes it. That is a supported topology, not a misconfiguration: `DiskSelector::recordDisk` permits a second plain-rewritable disk on an overlapping prefix only when that disk is readonly or write-once, `MergeTreeData::loadDataParts` arms a background part refresh when all disks are readonly, `SYSTEM RESTART DISK` exists to reload such a table, and six stateless tests use it. `loadMutations()` was never adapted to it and still assumes it exclusively owns a quiescent directory. It lists the directory and then reads every `mutation_*.txt` the listing returned. The owning table removes its own entries at arbitrary moments, through `killMutation` (from `KILL MUTATION` and from `MergeTreeTransaction::rollback`) and through `clearOldMutations`, so a removal landing between the listing and the read makes the read fail and takes the readonly table's `CREATE`/`ATTACH` down with it. Seen on master as `Code: 499 ... The specified key does not exist ... __root/mutation_5.txt` raised by `CREATE TABLE reader`, 63 ms after the stress harness's random `KILL MUTATION` deleted that object. An unreadable entry is now ignored only when all three of these hold, and the read failure stands otherwise: * the disk is readonly, so this table does not own the directory, * the object is proven absent at the backend, * no active part of this table is still below the mutation version. The third condition is what keeps the fix from trading an error for wrong results. The owning table decides that a mutation is finished from its own active parts, while this table cached its part set earlier, so a removed entry can still be owed as an on-the-fly alter conversion to an older part here; ignoring it would serve pre-mutation column data. The absence probe has to be `checkUniqueId(getUniqueId(...))` rather than `existsFile`: this disk's cached metadata is not invalidated when another disk instance over the same endpoint removes an object, and it was measured still reporting the removed entry as present while the backend reported it gone. A probe that cannot answer counts as "not proven absent": an empty unique id means the file has no backing object, which a present file can legitimately have when a metadata storage inlines small content or the file has zero blobs, so it must not be read as absence. The decision is taken entirely by the three conditions and never by the exception type, which also covers backends whose read failure is not a `DB::Exception`. The tolerated exception is deliberately not logged verbatim, because emitting its text would reproduce the object storage "key does not exist" message that log checks read as a server-side error. The same function also wrote to a disk it does not own. It persisted a CSN for a committed transactional mutation and removed uncommitted and temporary entries, and all three throw on `ReadOnlyDiskWrapper`, so a readonly table failed to attach over a directory holding such a file even with no race at all. Those writes are now skipped when the disk is readonly, with the CSN still assigned in memory so `system.mutations` reports it. The guard stays at this call site rather than inside `MergeTreeMutationEntry::writeCSN`, which is also the persistence step of transaction commit through `setMutationCSN`, where silently skipping it would hide a durability failure. One residual is accepted deliberately: a mutation cancelled above the readonly table's minimum part version is genuinely not owed to it, but a file that is simply gone cannot be told apart from a finished one, so that case still raises. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review (2 rounds; 2 findings agreed and fixed before publishing)Fixed in round 2:
Coverage, stated plainly: removing the tolerance, removing the minimum-part-version guard, or For whoever judges backporting: the race half needs a |
|
cc @alesapin @Michicosun, could you review this? |
|
Workflow [PR], commit [7bbdde4] Summary: ❌
AI ReviewSummaryThis PR lets a readonly Final VerdictStatus: ✅ Approve. No changes requested and no new inline findings to post. |
Build profile diff (arm_release)Commit See the job log for details. |
CI finish ledger - 24d531aEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
Session id: cron:our-pr-ci-monitor:20260910-120221 |
This does not cover a killed mutation that had not been applied yet, and I do not think a reader-side rule canMeasured on this head: the signature this PR targets fired again in What refuses is the third condition in Dropping the condition is not safe, and I could not find a reader-side predicate that is:
Options as I see them, and the tradeoff is yours:
Cost of leaving it as is: 15 Stress jobs in the 13 hours after #110939 merged, spread over 14 different My preference is the second option. Which would you prefer? |
Blocked on the hard links revert; I am not making CI green by weakening the test#119276 reverted #110939, so this PR's base has no I am not touching the branch for it. Tagging the test out of that configuration, or rebuilding the #119304 relands the feature as a plain revert of the revert (one commit, exactly inverse to #119276), |
…while a readonly table loaded A readonly `MergeTree` table over the directory of a live table (`table_disk` on the same `plain_rewritable` endpoint) does not own the `mutation_*.txt` entries there: the live table removes one at any moment (`KILL MUTATION`, `clearOldMutations`), also between the listing and the read in `loadMutations`. The read then failed with a raw `S3_ERROR` (`The specified key does not exist`), which is what reverted #110939: the stress test kills random mutations and treats every such error as a bug, see https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=3b3489bfd27660683f874666359fc92f58ca46b8&name_0=MasterCI&name_1=Stress%20test%20%28amd_debug%29 The table still cannot load without the entry - a part below its version would miss the commands, and no reader-side rule can tell a killed mutation from a finished one (see the analysis in #119154) - so the load still fails, but with `FILE_DOESNT_EXIST` and the reason: the entry was removed concurrently, and the attach can be retried after `SYSTEM DROP DISK METADATA CACHE` reloads the metadata of the readonly disk, which still lists the entry. The check probes the backend, because the cached metadata of the disk is exactly what is stale. Only a readonly disk takes this path. Related: #119154 Co-Authored-By: Claude Fable 5.1 <[email protected]>
Resolve the conflict with ClickHouse#119304 in `loadMutations` as agreed there: - keep the three writes this branch skips on a readonly disk (CSN kept in memory, an uncommitted entry ignored instead of removed, `tmp_mutation_*` left alone); - drop this branch's own backend probe, and let `loadMutationEntry` return nothing for an entry the owner removed when the caller allows it; the caller allows it only when no active part of the table is below the entry's version, otherwise `FILE_DOESNT_EXIST` from ClickHouse#119304 is thrown as before; - an empty unique id is not taken as proof that the entry is gone (a file without a backing object, e.g. with inline content), so the original read failure stays in force. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A SQL-defined local disk must now live inside `custom_local_disks_base_directory` (5b604cb), so the test uses `CLICKHOUSE_DISKS_FILES`, as 04318 does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merged master with #119304 and resolved One change from that comment: The category is now |
`loadMutationEntry` caught only `DB::Exception`, but the Azure read path rethrows the SDK's `Azure::Storage::StorageException` (404 "The specified blob does not exist") once the download fails, so on an Azure `plain_rewritable` readonly disk a mutation entry removed by the owner was neither skipped nor reported: `ATTACH` failed with `Code: 1001`. Catch `std::exception` instead. The reason is taken from `what()`, which for a `DB::Exception` is `message()`, so the rethrown `FILE_DOESNT_EXIST` text still carries no `Code: 499.` prefix for the stress log checks. 05161 now runs its scenario on a local and on an Azure disk, and its needed-entry arm also requires `FILE_DOESNT_EXIST`. On Azurite, the previous head fails the Azure arm 3/3 (`Code: 1001` on the finished entry, and the needed entry is not named), while the local arm passes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Storages/StorageMergeTree.cpp
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A readonly
MergeTreetable over the directory of a live table (table_disk = 1on a sharedplain_rewritabledisk) now attaches when the live table removes a mutation entry that no part of the readonly table still needs, and no longer writes to that directory while loading mutations.Description
Related: #110939, #119304.
Not for changelog:
enable_hard_linksexists only on master (#110939 was reverted before 26.9 and relanded by #119304), so no release has mutation entries in a sharedplain_rewritabledirectory.With
table_disk = 1, a readonly table over the sameplain_rewritableendpoint shares the directory of the live table that writes it. The live table removesmutation_*.txtentries at any moment (KILL MUTATION,clearOldMutations), also between the readonly listing and its read. Since #119304 theCREATE/ATTACHthen fails withFILE_DOESNT_EXISTand a retry hint.This PR, on top of
loadMutationEntryfrom #119304:DB::Exception(Azure rethrows the SDK's own).loadMutationsno longer writes to a directory the table does not own: the CSN is kept in memory, an uncommitted entry is ignored rather than removed, andtmp_mutation_*is left alone. Only the temporary-entry removal is reachable here (a plain-rewritable disk does not support transactions); the other two are defensive.Test
05161runs on a local and on an Azure disk. On master the first arm fails atATTACHwithCode: 107for a finished entry; with the change it passes. The second arm keeps the #119304 error for an entry a part still needs. Without thestd::exceptioncatch the Azure arm fails withCode: 1001. Same ons3_plain_rewritableover MinIO; the stress check for lost S3 keys finds nothing.05227passes.Workflow [PR]
Sync PR [sync-upstream/pr/119154]