Repository navigation
Revert "Revert "Support real hard links for plain_rewritable metadata."" - #119304
alexey-milovidov merged 21 commits into
Conversation
|
Workflow [PR], commit [ffb4b6d] Summary: ✅
AI ReviewSummaryThis PR re-lands Final Verdict
LLVM Coverage ReportMeasured on commit ffb4b6d.
Changed lines: Changed C/C++ lines covered: 742/816 (90.93%) · Uncovered code |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes36 object files changed (+409.59 KiB total), 2 added.
719 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 units295 translation units recompiled, 2938 s compile time in total, 293 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.94 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
Master reverted "Support real hard links for plain_rewritable metadata" (#110939) in 79745e1, so the operations this branch touches lost their explicit file lists. The reversal work is re-applied on the simpler code: - `MetadataStorageFromPlainObjectStorageHardLinkOperation` is gone, because `createHardLink` copies the blob again, which the copy operation covers. - `MetadataStorageFromPlainObjectStorageWriteFileOperation` no longer writes to object storage, so it has nothing to reverse and does not take `UndoRetries`. - The move of a file has a single form again, so its reversal no longer has a branch for a move that only rewrites file lists. - `prefix.path` holds a logical path again, so the tests read it directly. Everything the branch claims is unchanged: every stage of an `undo` repeats until object storage accepts it, each stage converges on the state recorded before the first write rather than on what `execute` saw succeed, and a blob that exists under neither its own key nor its temporary key is reported as a logical error. When #119304 restores the hard links, the reversals of the hard link operation, of `WriteFileOperation` and of the file move that only rewrites file lists need the same treatment again. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…t-110939-plain-rewritable-explicit-prefix-path # Conflicts: # src/Disks/DiskObjectStorage/MetadataStorages/PlainRewritable/MetadataStorageFromPlainRewritableObjectStorageOperations.cpp # src/Disks/tests/gtest_metadata_plain_rewritable_disk.cpp
Master (#119235) made every stage of a plain-rewritable undo repeat until object storage accepts it, because an undo that stops halfway leaves object storage describing a filesystem this process does not have. The undo stages that this branch adds - restoring the `prefix.path` of a directory whose explicit file list an operation rewrote - now go through `undoWithRetries` as well. Co-Authored-By: Claude Fable 5.1 <[email protected]>
… state With `enable_hard_links = 0` a hard link is a copy that runs at commit, and the transaction did not replay it: a later rewrite of the target in the same transaction planned as the creation of a missing file, chose the same default key, and the copy overwrote the new bytes at commit. The copy is now recorded in the uncommitted state like any created file, and a rewrite of its target in the same transaction supersedes the copy: the target directory keeps the implicit form, where a file has exactly one key, so the copy cannot go anywhere else and has nothing to contribute once the target is rewritten. Covered by the new `HardLinksDisabledRewriteLinkInTheSameTransaction` test. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ts parts `StorageMergeTree::drop` removed the `mutation_*` entries and the deduplication log of a `table_disk` table before `dropAllData` started. A drop that fails while removing the parts is retried by `DatabaseCatalog`, and `UNDROP TABLE` can still restore the table until then, so a failed drop could resurrect the table with all of its parts and without its mutation queue or deduplication history. The cleanup now runs from the late root-cleanup phase of `dropAllData`, after the parts are gone, through a `MergeTreeData` hook that the engines override for the files they keep in the root of the disk. The new test pauses a drop before it removes the parts and checks that a readonly table over the same directory still loads the mutation and the deduplication log. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…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]>
|
🕵 Merged master (3881 commits behind, conflicts with #119235 in the operations file and the gtest resolved: the undo flags renamed there are kept, and the The original #110939 was reverted because of the stress test: 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 harness kills random mutations, and a readonly @groeneai: this overlaps the same lines of |
|
Confirmed, and that is the resolution I will take on #119154. At merge time:
On the tolerance itself, since the comment cites my "no reader-side rule" note: that note is about telling a killed mutation from a finished one, which I still believe is undecidable on the reader side, and the guard does not try. It asks only whether any active part of this table is below the entry's version, that is, whether this table would ever apply that entry's commands as an on-the-fly conversion. If nothing is below it, the entry is irrelevant to every part in the set, killed or finished. If something is below it (mutation 15 over a part left at version 12, in the job I analysed) it refuses, which is exactly what the reland now reports with a reason. The two compose rather than compete. One measurement in favour of the reland, over the 20 Stress jobs this signature reddened from The tests do not overlap: |
…t-110939-plain-rewritable-explicit-prefix-path
…per` `ReadOnlyDiskWrapper` forwards the capabilities of the disk it wraps (`isWriteOnce`, `supportZeroCopyReplication`, `supportsCache`, ...), but not `supportsHardLinks`, so it fell back to `IDisk::supportsHardLinks`, which is `true`. A read-only attachment of a disk that cannot share blobs - a `plain_rewritable` disk without `enable_hard_links`, and before this pull request also any `plain` or write-once disk - therefore reported that the operations needing hard links are possible, while the disk it wraps reported the opposite. `ALTER` and mutations do not reach the capability check on such a table: `InterpreterAlterQuery` rejects it earlier with `TABLE_IS_PERMANENTLY_READ_ONLY`. The reachable caller is `InterpreterHypotheticalObjectQuery`, which mirrors the `ALTER` rule because a hypothetical index is only worth estimating on a table that could really get one. The new test `05234_read_only_disk_hard_links_capability` creates a read-only attachment of a `plain_rewritable` disk over the directory of a live table and checks that `CREATE HYPOTHETICAL INDEX` on it is refused with the same reason as on the writable table, and that with `enable_hard_links` both accept it - so the wrapper is not answering `false` unconditionally either. Without the fix the first arm accepts the index that the very same disk refuses. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…e_hard_links` The note said that servers older than `26.9` cannot read a directory with an explicit file list, which is a number this pull request cannot back: `26.9` is already branched off and master is `26.10`, so the boundary would be wrong even if the re-land lands today, and wrong downgrade guidance either blocks a safe downgrade or invites an unsupported mixed-version setup. The boundary is stated in terms of the feature instead - a server that does not have the `enable_hard_links` setting is exactly a server that cannot read the form, because reading it was added together with the setting. This is the wording already used next to the code, in `MetadataStorageFromPlainRewritableObjectStorage.h`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Merged master (1890 commits, no conflicts) and addressed both remaining review threads.
The CI reds on Locally against a build of the merged branch: |
…y probe fails The probe in `loadMutationEntry` (`getUniqueId` and `checkUniqueId`) can itself fail for reasons other than a removed object. It was outside of any `try`, so its exception replaced both the original read failure and the explanatory `FILE_DOESNT_EXIST`. Now the error is converted only when the probe proves that the object is gone; otherwise the original read failure is rethrown. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With `enable_hard_links = 0`, a later rewrite of the target of a copy that stands in for a hard link supersedes the copy. The bookkeeping in `fallback_copies` was keyed by the original target path and was not updated by `moveFile`, `replaceFile` and `moveDirectory`, so a new file written at the old path after the target was moved away superseded the copy that the move needs as its source. Drop the entries whose target is moved or replaced. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commit dropped the entry of `fallback_copies` when its target was moved. That turned a rewrite at the old path into a silent overwrite: the copy then ran at commit over the bytes the caller had written to the same default key. A moved copy cannot be superseded either, because the move needs it as the source, and the blob the move produces would overwrite the bytes of a rewrite at the new path. Now `moveFile`, `replaceFile` and `moveDirectory` mark the copy as moved under both the old and the new path, and `generateObjectKeyForPath` refuses to write such a path with `NOT_IMPLEMENTED` before any bytes are written. A moved copy without a rewrite still commits as before. Also pass `hard_links_enabled` in the `RefreshSkipsUnchangedDirectoryReads` test that came from master, which still used the two-argument constructor of `MetadataStorageFromPlainRewritableObjectStorage`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119304&sha=770425c6e0c802344e0e5c1dd64c8718765104f0&name_0=PR&name_1=Stress%20test%20%28arm_debug%29 ( |
|
Investigated. The job's fatal log names the aborting query, This is the row-policy route of #110518: the serialized plan shipped to the replicas loses the row policy that the initiator pushed into the The fix is in progress: #114955 (mine, open, CI green on its current head). It applies the policy on the executing server, so all replicas plan the same read, and its test |
`cppcoreguidelines-pro-type-member-init` failed the `Build (arm_tidy)` job: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119304&sha=9b2966bfe3052c83e6f3b36d9cb4f477a8eff530&name_0=PR&name_1=Build%20%28arm_tidy%29 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…it directory With `enable_hard_links = 0`, `createHardLink` copies the blob to the default key `<remote dir>/<file name>` of the target directory. That key is not free in a directory in the explicit form, written while hard links were enabled: a file removed there may leave its blob alive for a hard link elsewhere, and the copy would overwrite the bytes that link sees (and its undo would remove them). Now the copy into such a directory gets a fresh random key, chosen at planning time like a new file of the directory in `generateObjectKeyForPath`, and the key is listed in `prefix.path`. An implicit target directory keeps the default key. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e `FsSnapshot` of this branch The test came from master with the merge. On this branch `FsSnapshot` takes the shared `BlobLinkCounts`, and `FileRemoteInfo` has the `blob_key` field. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Pushed ffb4b6d:
@groeneai, thanks for the analysis of the |
|
A use case for |
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]>
…rrow-metadata-lock Reconcile with real hard links for `plain_rewritable` (#119304), which conflicted with the per-path locks, the replayed journal and the tombstone markers of this PR: - The journal of `FsSnapshot` also records `markDirectoryExplicit`, `addBlobLink` and `removeBlobLink`, and `FsMetadata::applyJournal` folds the replayed blob link deltas into the committed `BlobLinkCounts`. - A file operation that may rewrite the `prefix.path` of its directory (the directory has the explicit file list, the blob of the file is shared, or hard links are enabled) also locks the directory: the explicit file list lists all files of the directory, so two concurrent rewrites for different files would otherwise lose one of them. - `UnlinkMetadataFileOperation` and `MoveFileOperation` keep the metadata-only paths of master and use the tombstone markers on the paths that move blobs. `RemoveRecursiveOperation` chooses the blobs to delete in `execute`, keeping the shared ones, and deletes them before the `prefix.path` objects in `finalize`. - The initial load does not reclaim a blob of an orphaned directory that a live file still links to, rolls a pending removal back without losing the explicit file list, and lists `__root` for the leftovers of file removals even when the root has the explicit file list. - `getStorageObjectsIfExist` of a read-only disk maps the blob key of the target of a pending replacement to its backup. - Remove a no-op `std::move` of a const object flagged by clang-tidy.
…g arrayJoin allOutputsDependsOnlyOnAllowedNodes asks whether a key-expression node is determined by the query's reduced key nodes. Its ARRAY_JOIN arm was UNREACHABLE(), which encoded its original caller's precondition: until 6fe760d the only caller was isPartitionKeyFunctionOfKeys, walking a MergeTree partition key, and MergeTreeData::checkKeyExpression throws ILLEGAL_COLUMN "... key cannot contain array joins" for such a key, so the arm was genuinely dead. That commit gave the walker a second caller, StorageDistributed::isShardingKeySuitsQueryTreeNodeExpression, and nothing validates a Distributed sharding key the same way: checkShardingKeyExistsAndIsNumeric only requires one integer-representable output column, which cityHash64(k1, arrayJoin([1, 2]), k2) satisfies. The check moved but the precondition that justified it did not, so the arm became reachable from SQL. The pre-existing expression_dag.hasArrayJoin() early return does not cover it: that guards the query DAG, while the walk which reaches the arm starts at the sharding-key output and descends its children. matchTrees has no ARRAY_JOIN branch, so the node stays unmatched and the switch is always reached. I answer false instead of aborting. res is already false on entry to the switch, so break is the answer, and the arm previously carried no break at all. false is also the semantically correct answer, not just the safe one: an exploded array element is not a per-row function of its source row, so equal values may come from unrelated source rows lying on different shards, and the initiator's merge step is required. Claiming true would drop that step and return unmerged per-shard results. The sibling walker in this file already treats an ARRAY_JOIN result as irreducible for the same reason, and useDataParallelAggregation.cpp spells out the consequence for the walker's other caller. With false, isShardingKeySuitsQueryTreeNodeExpression returns false, getOptimizedQueryProcessingStageAnalyzer returns {}, and getQueryProcessingStage returns WithMergeableState, which is the path taken when optimize_distributed_group_by_sharding_key is off. No sharding key that works today changes behaviour, which the unchanged plan for cityHash64(k1, k2) confirms. This was the only aborting ARRAY_JOIN switch arm in src/. In an official release build the arm was __builtin_unreachable() carrying no break, so behaviour there was undefined; a 26.10.1.394 amd_release binary was measured to produce the same declining plan as this change, so release output is unchanged and what goes away is the debug and sanitizer build abort. The regression test drives a stored table definition rather than remote(...). An arrayJoin in a sharding key reaches the planner whenever a definition is replayed instead of stated (a short ATTACH, the tables of an ATTACH DATABASE, a Replicated database's DDL replay, a RESTORE, server startup), and that route keeps loading such a key regardless of whether stating one freshly is accepted, so it is the surface the fix has to hold on. Each assertion asks whether the initiator kept a merge step of its own, as SELECT count() > 0 FROM (EXPLAIN ...) WHERE explain ILIKE '%Distinct (DISTINCT)%' and the same over MergingAggregated. That is where the decision shows: taking the shortcut leaves nothing above the remote read, while declining it keeps the initiator's Distinct or MergingAggregated step. An ordinary key is asserted in the same file as the control, pinning the zero side, so the reference also fails if the optimization stops firing. Found by the AST fuzzer on Stress test (amd_tsan), PR ClickHouse#119304, commit f1cd2ee. Co-Authored-By: Claude Opus 5 <[email protected]>
Reverts #119276, i.e. re-lands #110939 (real hard links for
plain_rewritablemetadata via explicit file lists inprefix.path, opt-in withenable_hard_links), with the fixes below on top.Closes: #91611
Related: #119154
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Disks with the
plain_rewritablemetadata (s3_plain_rewritable, andazure/localobject storages withmetadata_type = plain_rewritable) support hard links if configured with the newenable_hard_linkssetting, which enablesALTERoperations and mutations onMergeTreetables stored on them. Mutations and partition operations share the unchanged blobs between parts instead of copying them. The setting is off by default, because a disk that has hard links cannot be read by older servers.Details
The original change was reverted because the stress test kills random mutations, and a readonly
table_diskreader over a live table's directory (the new test05104) then failed to load with a rawS3_ERRORThe specified key does not existfor amutation_*.txtentry that the owner removed between the listing and the read (report). Compared to #110939:loadMutationsof a readonly table reports a concurrently removed entry asFILE_DOESNT_EXISTwith the reason and the way to retry (SYSTEM DROP DISK METADATA CACHEand attach again), instead of a missing object. The table still refuses to load without the entry: a reader cannot tell a killed mutation from a finished one (see Tolerate a concurrently removed mutation entry on a readonly shared directory #119154 (comment)). Test05227reproduces the race with a pauseable failpoint.enable_hard_links = 0, the copy that stands in for a hard link is replayed in the uncommitted state, and a rewrite of its target in the same transaction supersedes it (the copy would otherwise overwrite the new bytes at commit).table_diskcleanup ofmutation_*entries and the deduplication log onDROP TABLEruns after the parts are removed, so a failed drop can still be retried or undone with them. Test05228checks it with a pauseable failpoint.prefix.pathundo rewrites go throughundoWithRetries, like every other undo stage since Retry every stage of a plain-rewritable undo until it succeeds #119235.ReadOnlyDiskWrapperforwardssupportsHardLinksto the disk it wraps, instead of falling back toIDisk::supportsHardLinks, which istrue. Without it a read-only attachment of a disk that cannot share blobs offers the operations that need hard links while the disk it wraps refuses them. This is older thanenable_hard_links- the same was true of a read-only attachment of aplainor write-once disk - but the new setting widens the set of disks it is wrong about. Test05234.enable_hard_linksstates the boundary as "a server that does not have the setting" instead of naming a release, which this change cannot pin down.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/119304]
Version info
26.10.1.1609-master(included in26.10and later)