Repository navigation
Remove parts on plain_rewritable disks without copying their files - #123303
alexey-milovidov merged 3 commits into
Conversation
`DataPartStorageOnDiskBase::clearDirectory` removes a complete part file by file (`removeSharedFiles` + `removeDirectory`). On a disk with `plain_rewritable` metadata every `unlinkFile` is a `MetadataStorageFromPlainObjectStorageUnlinkMetadataFileOperation`, which copies the blob to a temporary `__root/<random>` key so that the unlink can be undone, deletes the source, and deletes the copy in `finalize`. The copy and the source delete run inside `commit` under the disk-wide metadata mutex, so outdated-part cleanup, `TRUNCATE`, `DROP PARTITION` and `DROP TABLE` issue one `CopyObject` (a multipart copy for big files) and two deletes per file, and every other metadata write on the disk queues behind them (issue ClickHouse#123275: `S3CopyObject` at 3.2/s sustained, 41k outdated parts backlogged). The recursive branch, so far used only for incomplete or empty-checksum parts, maps to `MetadataStorageFromPlainObjectStorageRemoveRecursiveOperation`: one `prefix.path` PUT per directory under the mutex, and one batched `removeObjectsIfExist` for all objects in `finalize`, with no copies. The copy in the unlink operation stays: it is what makes the unlink roll back with the transaction. Add `IDisk::prefersRecursiveRemoval`, false by default (on local disks the per-file branch is the fast path). `DiskObjectStorage` answers true for `plain_rewritable` metadata, which the cache metadata wrapper forwards through `getType`, and `DiskEncrypted` forwards it to its delegate. `clearDirectory` takes the recursive branch when the disk prefers it. Both branches ignore the keep-shared-data inputs on `plain_rewritable`, so the deleted objects are the same; the only thing dropped is the "Cannot quickly remove directory" log for unexpected files in a part directory. Measured on a local MinIO, `TRUNCATE` of 200 wide parts with 20 columns: 133.9 s, 27,400 `CopyObject` and 55,200 delete calls before; 12.4 s, 0 copies and 400 delete calls after. Closes ClickHouse#123275 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Say the recursive removal deletes objects in bulk, not in one request (deletes are batched). 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; 3 findings) plus my own review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261001-162700 |
|
Workflow [PR], commit [6d30cd2] Summary: ✅
AI ReviewSummaryThis PR switches Final Verdict
LLVM Coverage ReportMeasured on commit 6d30cd2.
Changed lines: Changed C/C++ lines covered: 15/17 (88.24%) · Uncovered code |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Amazing! Thank you 💌
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units1045 translation units recompiled, 7711 s compile time in total, 1045 of them have a recent master baseline. |
Backport #123303 to 26.9: Remove parts on `plain_rewritable` disks without copying their files
Backport #123303 to 26.8: Remove parts on `plain_rewritable` disks without copying their files
Closes: #123275
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Removing data parts from a disk with
metadata_type = plain_rewritable(cleanup of outdated parts,TRUNCATE,DROP PARTITION,DROP TABLE) no longer copies every file of the part to a temporary object before deleting it, and no longer holds the disk metadata lock for those copies. The part directory is removed with one batched delete request. Closes #123275.Description
DataPartStorageOnDiskBase::clearDirectoryremoved a complete part file by file. Onplain_rewritableeach file unlink copies the blob to a temporary key (so the unlink can roll back), deletes the source and later the copy, and the copy and delete run under the disk-wide metadata lock. The recursive removal, so far used only for incomplete parts, moves the directory metadata and deletes all objects after the lock, with no copies.This adds
IDisk::prefersRecursiveRemoval(false by default; local disks keep the per-file path).DiskObjectStoragereturns true forplain_rewritablemetadata, also behind acachedisk,DiskEncryptedforwards it, andclearDirectorytakes the recursive branch when it is set. The unlink operation is unchanged: as @ Michicosun noted on the issue, its copy is what makes the transaction rollback work.Both branches delete the same objects on these disks. The only thing dropped is the
Cannot quickly remove directoryerror log for unexpected files in a part directory. Listing a directory is in memory onplain_rewritable, so I can keep that check if you prefer.TRUNCATEof 200 wide parts with 20 columns, local MinIO:CopyObjectThe new test checks that
TRUNCATEmakes no copies ons3_plain_rewritableand onencrypted_s3_plain_rewritable_cache. It fails on master. The existingplain_rewritablestateless tests and the integration testtest_s3_plain_rewritable, which checks the bucket is empty afterDROP TABLE SYNC, pass.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123303]
Version info
26.10.1.1258-master(included in26.10and later)26.9.32.13,26.8.41.7