Repository navigation
Cherry pick #132449 to 26.10: Fix INSERT into a Set or Join table on a plain_rewritable disk - #133610
Conversation
…rectory A new `Set` or `Join` table on a `plain_rewritable` disk creates `<path>/tmp` with `createDirectories`, which records only the leaf, so `<path>` exists only as a virtual node. The first INSERT then `replaceFile`s `tmp/<n>.bin` into it and the commit throws `LOGICAL_ERROR: Directory '...' is virtual`. The stateless test covers the Set/Join INSERT. The gtests cover a move and a hard link (also with hard links disabled) into a virtual directory, a concurrent removal of the virtual target, and a concurrent replacement of it by a directory in the explicit form. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… or linked into it On a `plain_rewritable` disk `createDirectoryRecursive` writes a `prefix.path` only for the leaf, so its ancestors exist only as virtual nodes. Writing a file into such a directory already materializes it (#91935, in `generateObjectKeyForPath`), but `moveFile`/`replaceFile` and `createHardLink` did not, and their commit threw `LOGICAL_ERROR: Directory '...' is virtual`. That is hit by the first INSERT into every `Set`/`Join` table on such a disk (`StorageSetOrJoinBase::restore` creates `<path>/tmp`, and the INSERT then `replaceFile`s `tmp/<n>.bin` into `<path>`), by a `Join` mutation, and by `clickhouse-disks move`/`link`. The new `materializeVirtualDirectory` is called for the target directory of a move and of a hard link. It plans a `CreateDirectoryOperation` for it in a new materialize-only mode and records the directory in the uncommitted state, so the move or link plans against a real, empty, implicit directory. Like the write path, it registers `useMissingDirectory`, so a commit fails with `DIRECTORY_ALREADY_EXISTS` when another transaction materialized or replaced the directory in between (the move, the real hard link and the hard-links-disabled copy were all planned for the implicit form). The materialize-only operation throws `DIRECTORY_DOESNT_EXIST` when the directory was removed in between, instead of recreating it. A target directory that does not exist at all still fails as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the sentence in materializeVirtualDirectory that narrated the new code's useMissingDirectory precondition (it is in the fix commit message). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review: #132449 (review) The target directory of a move or a hard link is now materialized exactly as `generateObjectKeyForPath` materializes the parent of a new file: `useMissingDirectory` plus `createDirectoryRecursive`. The `materialize_only` mode of `CreateDirectoryOperation` is removed, so the operations are the same as on master. As for a write, a target directory removed by a concurrent transaction after the move was planned is recreated by the move instead of failing it. The `ConcurrentRemoveOfVirtualMoveTarget` test, which pinned the removed mode, is dropped. A move into a directory that does not exist at all still fails as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to-virtual-dir Fix `INSERT` into a `Set` or `Join` table on a `plain_rewritable` disk
Resolve the conflict in gtest_metadata_plain_rewritable_disk.cpp: keep the 26.10 side of the `ErrorCodes` declarations and add only `DIRECTORY_ALREADY_EXISTS`. The conflicting master line, `INCORRECT_DATA`, comes from #121431, which is not on 26.10 and is not needed by these tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The only conflict is one line in The bug is present on 26.10: with the official 26.10.11.7 build, the first I cannot push to |
|
🕵 Applied the resolution from the comment above: I checked it independently: the diff against |
Original pull-request #132449
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job