Repository navigation
Add borrow_from_cache object storage and memory metadata types - #100371
alexey-milovidov wants to merge 287 commits into
Conversation
|
Workflow [PR], commit [af620e0] Summary: ❌
|
…dicate - Remove unused `DIRECTORY_DOESNT_EXIST` error code from `MetadataStorageInMemory.cpp` (style check failure) - Remove default argument values from override declarations in `BorrowFromCacheObjectStorage` to fix `google-default-arguments` clang-tidy error - Guard `removeRecursive` against null `should_remove_objects` predicate and pass relative paths to match the predicate contract #100371 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
The flaky check failure is fixed in #102148, let's update the branch. |
…set explicitly The previous check relied on `compatibility_type_hint == "memory"`, but the hint is only populated when `metadata_type` is absent from the config. With `metadata_type = 'local'` set explicitly, the hint stays empty and the check was bypassed, allowing a misconfiguration the test `04141_borrow_from_cache_metadata_check` exists to reject. Use the actual `ObjectStorageType` of the local location instead, so the enforcement triggers regardless of whether `metadata_type` is set explicitly. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100371&sha=b9bc6622d4fc456f6196c00d34ebd5ad505638fa PR: #100371 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… `mutate_mutex` `INSERT INTO j SELECT ... FROM j` holds the read lock of its source. A concurrent persistent insert that holds `mutate_mutex` while publishing its backup waits for the write lock, so waiting on `mutate_mutex` in `StorageJoin::write` was a lock cycle. Check that the insert is possible before taking `mutate_mutex`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a cached disk A lost invalidation can leave stale cache entries for reused blob paths on cached `plain` and `plain_rewritable` disks. The bookkeeping only allocates a few small nodes, so do not let the memory limits of the query or the user make it fail. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged
|
`DiskObjectStorageOverInMemoryMetadataTest.AppendToInlinedFileIsRejected` required the append to an inline-backed file to throw. The private build moves the inline content to a blob before the append instead, which is equally correct. The test now checks the actual invariant: the file never carries the stale inline payload next to a blob, and its content is either the original one (rejected append) or the whole appended one. `05453_borrow_from_cache_wrapper_rollback_reclaims_segments` exceeded the time limit of the flaky check with the default disk on S3: every background write of the server commits through the one-shot failpoint and consumes it, so the retries take too long. Tag it `no-object-storage`. Sync PR: ClickHouse/clickhouse-private#53277 Related: #100371 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Pushed
The two open review threads (the replay cost of a persistent |
…k through a `cache` disk `DiskObjectStorageTransaction::undo` called `removeObjectsOfFailedTransaction` for every disk, and `CachedObjectStorage` forwards it to the storage it wraps. On a cached `plain_rewritable` disk an ordinary file overwritten in place reuses the key of its existing blob, so a failed copy or write whose commit is rolled back would physically remove a blob that the committed metadata still references. Forward the physical removal only when the metadata storage generates random blob paths (as `memory` metadata over `borrow_from_cache` does), so every written blob is owned by the failed transaction; otherwise keep the previous behaviour of `removeObjectsIfExist`, which for a `cache` disk only drops the cache entries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Pushed
|
# Conflicts: # src/Storages/StorageJoin.cpp
…_insert` The test, added on `master`, checks that a `Join` insert which throws partway through a block keeps the keys inserted before the throw. This PR makes persistent `Join` inserts atomic: they stage their blocks in a backup file and are rolled back as a whole on failure, so the table stays empty and the `scan > 0` check failed in the Fast test. Only a non-persistent table still inserts blocks directly into the live state, so use `persistent = 0` to keep testing the partial-insert path. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=100371&sha=latest&name_0=PR&name_1=Fast%20test #100371 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged
|
|
🕵 |
…bject-storage Conflict in `DiskObjectStorageTransaction::undo`: master now removes the blobs of an undone transaction through every layer (`getUnderlying`) down to the base object storage. This subsumes the PR's `removeObjectsOfFailedTransaction`, which is removed. The PR's guard is kept: the blobs are removed below the outermost layer only when the blob paths are random (`areBlobPathsRandom`), so an in-place overwrite of a `plain_rewritable` file under a cache does not delete the committed object. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…row_from_cache_zero_copy_two_replicas` The style check requires queries to `system.text_log` to be bounded by `event_time`, since a full scan exceeds `max_rows_to_read` on CI. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=100371&sha=2600974e83b033594cea65469e9ec59d89e39dc7&name_0=PR&name_1=Style%20check Related: #100371 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…bject-storage Resolve the conflict in `StorageSet.cpp` by keeping both `onException` of this PR and `onPipelineFinished` from master; guard `onPipelineFinished` with `insert_finished` so that a pipeline cancelled after a successful `onFinish` does not publish the backup twice.
…type analysis `StorageJoin::joinGetCheckAndGetReturnType` read `join` without `rwlock`, while a failed persistent `INSERT` (and its lost-state recovery), a mutation or `TRUNCATE` replace it under the write lock and may destroy the old `HashJoin`. `JoinGetOverloadResolver::buildImpl` calls it before taking any table lock, so a concurrent `joinGet` analysis could use a destroyed object. Take the read lock with the query context, like `joinGet` itself does. Add a test running `joinGet` analyses concurrently with persistent inserts that exceed `max_rows_in_join` and are rolled back. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rages `master` enabled the `modernize-use-nodiscard` clang-tidy check; the functions this PR adds to `IMetadataStorage` and `MetadataStorageInMemory` would fail the clang-tidy build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged
|
The style check (`functional_tests_check`) rejects test names that include `fail`: `05829_storage_join_joinget_analysis_during_failed_insert` is now `05829_storage_join_joinget_analysis_during_rejected_insert`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=100371&sha=90cfba513f93db66640d7b1578662ca942a79f95&name_0=PR&name_1=Style%20check #100371 Co-Authored-By: Claude Fable 5.2 <[email protected]>
`modernize-use-nodiscard` flagged `countBlobs` and `readThroughDisk` in the `arm_tidy` build. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=100371&sha=90cfba513f93db66640d7b1578662ca942a79f95&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 #100371 Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged
|
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=4 K_base=24 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
…aster
`chmod` and `supportsChmod` were removed from the disk and metadata storage
interfaces on master ("Remove unused `chmod` and `supportsChmod` from disks"),
so the overrides in `MetadataStorageInMemory` and its transaction no longer
override anything and the merged tree did not compile.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…mmitted transaction `MetadataStorageFromCacheObjectStorageTransaction` queues the blobs removed by the underlying transaction after the commit, so that the blob killer drops their cache entries. If that bookkeeping failed, the failure was logged and the blobs were forgotten. On a cached `plain_rewritable` disk a later file can reuse the path of a removed blob, and the stale cache entry would then be served for it. Retain the committed underlying transaction, which knows the removed blobs, in the metadata storage, and queue its blobs on the next round of the blob killer. The list node that holds it is allocated when the transaction is created, so retaining it after the commit does not allocate and cannot fail. Until the blobs are queued, `hasPendingRemovalBlobs` reports them as pending, as it does for queued blobs, and `hasDeadBlobsQueue` keeps the blob killer polling. The commit still never fails after the metadata is committed, so committed blobs are not rolled back. Also keep the two containers of `InMemoryRemovalQueue` in sync if the second insertion throws: a retried `submitForRemoval` would otherwise leave a blob in the queue that is never forgotten. #100371 (comment) Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ts own backup `StorageSet::publishBackup` built a new `Set` from all committed backups on every persistent `INSERT` and swapped it in. With `persistent = 1` (the default) that made every insert cost as much as the whole table: repeated small inserts were quadratic, and two full copies of the table were kept in memory during each of them. Replay only the promoted backup of the `INSERT` into the live `Set`, as it was done before this pull request. If the replay fails, the state is rebuilt from the other committed backups and swapped in, so the queries started afterwards see exactly the committed rows, and the backup of the failed insert is discarded as before. If the rebuild fails as well, the state is marked as lost: `getSet` throws `NOT_INITIALIZED` instead of handing out a `Set` with rows of the failed insert, and the next `INSERT` rebuilds it. This intentionally gives up one property of the previous approach: a query that is already running can observe the rows of an `INSERT` while it is being published, and keeps the rows of a failed one until it finishes. That is how `Set` behaves on master. The test that pinned the opposite, `05150_storage_set_persistent_insert_not_visible_mid_replay`, and its failpoint are removed. `05872_storage_set_failed_insert_rollback_failure_is_not_visible` covers the failed rollback. 300 single-row inserts into a persistent `Set` of 3 million rows now take about a second in total in `clickhouse local`. #100371 (comment) Co-Authored-By: Claude Fable 5.2 <[email protected]>
Add a new object storage type
borrow_from_cachethat allocates space in a named filesystem cache using ephemeralFileSegments. Each stored object is backed by a cache segment held alive viaFileSegmentsHolder; when released, the cache reclaims the space.Add a new metadata type
memorythat keeps all file-to-blob mappings and directory structure entirely in memory with no persistence. On server restart all data is lost, which is acceptable for the intended use case of temporary tables.Configuration example:
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A new object storage type and metadata type suitable for temporary tables. Add a new object storage type
borrow_from_cachethat allocates space in a named filesystem cache and holds it from eviction. Add a new metadata storage typememorythat keeps the mapping in memory. For example, this could allow creating temporary tables with custom engines in the Cloud without using S3. Closes #75551.Workflow [PR]
Sync PR [sync-upstream/pr/100371]