Repository navigation
Allow creating a directory on top of virtual plain-rewritable node - #91935
Conversation
|
Workflow [PR], commit [2e300d3] Summary: ❌
|
|
Also, maybe a better approach will be to materialize the virtual directory during file creation, because I am not sure that the parent directory after a child recursive create will always be explicitly created before the file creation. like this sequence wdyt? |
29e88e2 to
2da5f8e
Compare
I added directory materialization before It probably makes sense to remove the |
|
DEBUG_OR_SANITIZER_BUILD macro is because sanitizer builds abort on LOGICAL_ERROR |
2da5f8e to
5256a01
Compare
… 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 (ClickHouse#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]>
Fixes: #89476
This happens because plain-rewritable does not allow creating a physical directory (backed by an object in the object storage), if the node in the directory tree already exists and is virtual.
In the example with backup, the following operations are executed:
createDirectories("backup0/metadata/d0/")
writeFile("backup0/metadata/d0.sql")
createDirectories("backup0/metadata/") <== Physical directory is not created
writeFile("backup0/metadata/d0.sql") <== LOGICAL_ERROR
This PR relaxes virtual node checks.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
Directory '{}' does not exist (LOGICAL_ERROR)when creating backups on plain-rewritable disks.Documentation entry for user-facing changes