Skip to content

Do not overwrite files on S3Queue move destination collision - #115724

Open
valerypetrov wants to merge 134 commits into
ClickHouse:masterfrom
valerypetrov:fix/s3queue-move-collision-114847
Open

valerypetrov wants to merge 134 commits into
ClickHouse:masterfrom
valerypetrov:fix/s3queue-move-collision-114847

Conversation

@valerypetrov

@valerypetrov valerypetrov commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #114847

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixed silent data loss in S3Queue/AzureQueue after_processing = 'move': with the default after_processing_move_preserve_path = 0, objects sharing a basename under different prefixes mapped to the same destination key, so the second move overwrote the first object's data and then deleted its own source. Colliding objects are now left in place with an error logged; the destination guard is enforced by the object storage itself, so concurrent movers cannot both overwrite.

Documentation entry for user-facing changes

The move is copy-then-delete per object, and an S3/Azure overwrite is not an error, so the collision destroyed one file's bytes with no exception, no log line, and ObjectStorageQueueMovedObjects counting both moves as successful.

The fix detects collisions at two levels and, on collision, refuses the move: the object stays at the source (it is already recorded as processed, so it is simply retained in the bucket for the operator), an error is logged, and the new ObjectStorageQueueMoveCollisions profile event is incremented.

  • Within a processing batch (all storages, no extra requests): destinations are deduplicated while scheduling; only the first object mapping to a given key is moved.
  • Everywhere else — across batches, replicas and concurrent movers: the copy itself carries a destination precondition (If-None-Match: *), so the storage refuses it rather than overwriting. This is applied on all three move paths (same-bucket, cross-bucket S3, cross-container Azure) whenever after_processing_move_preserve_path = 0; preserved paths cannot collide, so they are unconditional as before. GCS cannot refuse such an overwrite, so CREATE and ALTER refuse a flattening move to GCS. It costs no extra request: the precondition rides on the request that makes the object visible.

Because the guard is enforced by the storage rather than by a preflight check, there is no check-then-copy window: of two movers racing for the same destination exactly one wins, and the loser keeps its source. A rejected copy is reported as a collision (logged, counted by ObjectStorageQueueMoveCollisions) and never followed by the source deletion.

To carry the precondition, the S3 copy helpers accept S3CopyFileSettings, while the Azure copy helpers accept an optional destination If-None-Match. Each sets it on the request that commits the object (PutObject / CopyObject / CompleteMultipartUpload, and Upload / CommitBlockList / CopyFromUri / StartCopyFromUri). The parameter defaults to "no precondition", so every existing caller is unchanged. S3ObjectStorage::copyObject now forwards its WriteSettings, which it previously discarded, so object_storage_write_if_none_match reaches the copy.

The copy is no longer re-executed by the retry loop once it has succeeded, so a failure while removing the source cannot make the retry collide with the object this move just wrote. The source delete is pinned to the copied generation, by versionId on versioned buckets and by If-Match otherwise; a store that ignores If-Match on DELETE (MinIO does) deletes by key there, as before this change. GCS rejects ETag conditions on deletes, so no condition is sent to it and it deletes by key as well. On a versioned bucket only the version that was read is removed, so an older version of the key, if there is one, becomes the current object again. The listing reports no version IDs, so the read is pinned to the listed ETag only: if the same bytes are uploaded again between the listing and the read, the new version is the one read and removed, and the listed version stays at the key.

A move that would put an object onto its own key (e.g. a prefixless after_processing_move_uri pointing at the source bucket with other keys, or a flattening prefix that maps a/x to itself) is refused the same way: the object stays in place, an error is logged, and ObjectStorageQueueMoveCollisions is incremented. A destination bucket with the source bucket's name is taken as the source bucket whatever its endpoint is, as is any bucket when either side is addressed through an S3 access point (an alias, an access point or Object Lambda host, or a Multi-Region Access Point), because its name does not identify the bucket; and an Azure destination is compared by the blob path only: distinct hosts or ports (a host name and its IP address, a CNAME, a private endpoint) do not prove that the services are distinct.

A move that uploads the object again restates what CopyObject carries for free: the user metadata, the headers (Content-Type, Content-Encoding, Cache-Control and the like) and, with after_processing_move_preserve_tags = 1, the tags. This applies to guarded moves and to unguarded moves that cannot use CopyObject (another endpoint, other access keys, or allow_native_copy = 0).

_tags are taken from the generation that was consumed. On unversioned objects, HeadObject is repeated after GetObjectTagging, so tags of an object rewritten in between are never attributed to the earlier generation; such a file is reset and read again.

Setting after_processing_move_preserve_path = 1 remains the recommended configuration when same-basename objects are possible, and the after_processing_move_preserve_path setting description now documents the collision behavior.

Integration tests cover in-batch and pre-existing collisions, same-storage and external moves for S3Queue/AzureQueue, interrupted-copy recovery, S3 headers and tags and Azure metadata on flattening moves, versioned-source provenance, and a same-byte re-upload between the listing and the read.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/115724]

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Aug 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [abefcb1]

Summary: ✅


AI Review

Summary

The PR prevents flattened S3Queue/AzureQueue moves from overwriting existing destinations and adds source-generation checks, retry recovery, and property preservation. Reviewed head abefcb1058fd5b172746c2653c35708e969f78f4. No new inline findings; two previously dismissed concerns remain in the current code and are retained below without replying to or reopening their threads.

Missing context / blind spots
  • ⚠️ No local build or test run was performed. The fetched Praktika report reports no failures, but its targeted integration jobs contain zero test results; completed targeted CI is still needed for runtime validation.
Findings

❌ Blockers

  • src/Storages/ObjectStorageQueue/registerQueueStorage.cpp:107 — Explicit versionId=null silently selects different data after upgrade. [dismissed by author -- https://github.com/Do not overwrite files on S3Queue move destination collision #115724#discussion_r4449173348] The selector is cleared for every queue, including after_processing = 'keep'. Upload payload A before enabling versioning, then payload B afterwards: an existing queue explicitly selecting ?versionId=null now reads B instead of A. No concurrent rewrite is needed. The author's destructive-action rationale does not explain changing a KEEP queue's requested version. Preserve the explicit selector separately from the immutable-generation identifier, with ETag validation for a mutable version, or provide a compatibility control and migration guidance.

  • src/Storages/ObjectStorageQueue/StorageObjectStorageQueue.cpp:877, ObjectStorageQueueSource.cpp:2371 — Independent committing queries can skip a rewritten ordered file permanently. [dismissed by author -- https://github.com/Do not overwrite files on S3Queue move destination collision #115724#discussion_r4319088403] With mode = 'ordered', buckets = 1, and commit_on_select = 1, query A can claim a.csv while query B skips that claim and consumes b.csv. If A detects a changed generation and resets a.csv, B's independent reread map remains empty and its commit advances the shared pointer to b.csv; the replacement of a.csv is then filtered out permanently. Limiting each query to one source does not coordinate different queries. The author deliberately defers this pre-existing concurrency problem; that does not remove the current data-loss path. Serialize these consumers or share their reread barrier, or link a tracking issue documenting this unsupported concurrency so the design change can be handled separately.

Tests
  • ⚠️ Add a KEEP variant of the explicit null-version regression with different historical/current payloads, asserting that the requested historical payload is returned. The current deletion test explicitly expects the changed selection.
  • ⚠️ If the ordered race is fixed here, cover two concurrent committing SELECT queries; the existing single-query regression cannot exercise independent iterators and commits. Otherwise include that reproduction in the tracking issue.
Final Verdict

Status: ❌ Block

Preserve explicit null-version selection or provide a compatibility path. Address the independent-query ordered-pointer race, or link a tracking issue accepting its separate scope. Both findings remain summary-only because the author already dismissed them.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing abefcb105 with master d5206181a (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

191 object files changed (+648.31 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorageQueue/ObjectStorageQueuePostProcessor.cpp.o 396.22 KiB 585.87 KiB +189.65 KiB (+47.86%)
src/CMakeFiles/dbms.dir/Storages/ObjectStorageQueue/ObjectStorageQueueSource.cpp.o 1007.93 KiB 1.08 MiB +99.04 KiB (+9.83%)
src/CMakeFiles/clickhouse_common_io.dir/IO/S3/copyS3File.cpp.o 690.80 KiB 754.24 KiB +63.45 KiB (+9.18%)
src/CMakeFiles/clickhouse_common_io.dir/Disks/DiskObjectStorage/ObjectStorages/AzureBlobStorage/Azu… 510.50 KiB 542.80 KiB +32.30 KiB (+6.33%)
src/CMakeFiles/dbms.dir/Disks/DiskObjectStorage/ObjectStorages/AzureBlobStorage/AzureObjectStorage.… 510.48 KiB 542.77 KiB +32.29 KiB (+6.33%)
src/CMakeFiles/clickhouse_common_io.dir/IO/S3/getObjectInfo.cpp.o 308.34 KiB 335.75 KiB +27.41 KiB (+8.89%)
src/CMakeFiles/dbms.dir/Disks/DiskObjectStorage/ObjectStorages/S3/S3ObjectStorage.cpp.o 570.15 KiB 592.84 KiB +22.68 KiB (+3.98%)
src/CMakeFiles/dbms.dir/Storages/ObjectStorageQueue/StorageObjectStorageQueue.cpp.o 1.21 MiB 1.23 MiB +22.34 KiB (+1.80%)
src/CMakeFiles/dbms.dir/IO/AzureBlobStorage/copyAzureBlobStorageFile.cpp.o 287.61 KiB 309.60 KiB +21.99 KiB (+7.65%)
src/CMakeFiles/clickhouse_common_io.dir/IO/AzureBlobStorage/copyAzureBlobStorageFile.cpp.o 287.64 KiB 309.62 KiB +21.99 KiB (+7.64%)
src/CMakeFiles/clickhouse_common_io.dir/IO/ReadBufferFromS3.cpp.o 383.88 KiB 401.59 KiB +17.71 KiB (+4.61%)
src/CMakeFiles/clickhouse_common_io.dir/IO/S3/deleteFileFromS3.cpp.o 348.33 KiB 364.34 KiB +16.01 KiB (+4.60%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

1842 translation units recompiled, 9283 s compile time in total, 1842 of them have a recent master baseline.

Symbol sizes
Binary Symbol Master PR Δ
programs/clickhouse ProfileEvents::global_counters_storage 14.69 MiB 14.75 MiB +64.00 KiB (+0.43%)

Job report

Comment thread src/IO/S3/copyS3File.cpp Resolved
@valerypetrov
valerypetrov force-pushed the fix/s3queue-move-collision-114847 branch from 5fefabb to d4da636 Compare August 23, 2026 17:52
Comment thread src/IO/S3/copyS3File.cpp Resolved
Comment thread src/IO/S3/getObjectInfo.cpp Resolved
@valerypetrov

Copy link
Copy Markdown
Contributor Author

Update: both blockers are addressed.

  • after_processing_move_preserve_tags = 1 now requests GetObjectTagging explicitly via with_tags = true and fails closed when the tag set cannot be read (094198e, a037472).
  • The own-committed-copy proof now uses a source-version identifier that survives new attempts/restarts, instead of the per-attempt move_token (7c5db5b).

alexey-milovidov and others added 2 commits November 17, 2026 06:18
…ibes

A queue whose URL selects a version requests the tags of that version, but the `One` format also consumes keys that have no such version. These keep the listed metadata of their latest version, and the version-specific tag lookup failed them with `FILE_DOESNT_EXIST`. Background ingestion requests every virtual column, so this aborted the batch in `test_failed_lookup_of_the_selected_version_keeps_the_ordered_position`. Now the selected version's tags are fetched only when the file's metadata is that version; otherwise the tags of the key are taken, consistent with the other metadata virtual columns.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115724&sha=a69d192ef08de9666e20c4107ee8e0cbcd8f605b&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20targeted%29
ClickHouse#115724

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 5 commits November 17, 2026 09:13
Without a `versionId` in the URL, `_tags` were read from the latest version of the key. With `One` the consumed version is claimed before the tag lookup, so a version uploaded in between combined the claimed version's `_etag` with the new version's tags, while post-processing acted on the claimed version. Now the tags of a claimed version are requested by its `versionId`. Formats that read bytes learn their version only after the tags are fetched, so the generation of the tags (from `HeadObject`) is checked against the generation that was read, and a mismatch resets the file like any other rewrite during the read. `getObjectInfo` also checks that `GetObjectTagging` describes the version reported by `HeadObject`.

A new failpoint `object_storage_queue_pause_before_tags_fetch` is used by the regression test `test_tags_of_the_version_the_one_format_consumed`.

ClickHouse#115724

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rned

A format that reads bytes learns the version it read only from the response,
which arrives after the tags are fetched. The check that the tags describe the
generation that was read ran only at the end of the file, after the rows had
already been returned: a direct `SELECT ... LIMIT 1` could emit them, and a
materialized view with `MergeTree` commits each chunk, so failing at the end of
the file did not roll them back.

Now each chunk is checked against the generation reported by the read buffer
before it is returned. A mismatch on the first chunk resets the file to be read
again; a mismatch after rows were returned fails the insert. The end-of-file
check is kept for files without rows.

`ReadBufferFromS3::getMetadata` now reads only the response fields that
`sendRequest` records under the mutex, instead of `impl`, so it may be called
while a prefetch or parallel parsing reads the buffer.

Add the failpoint `object_storage_queue_pause_after_tags_fetch` and the
regression test `test_tags_of_the_version_a_byte_reading_format_consumed`: the
tags are fetched from a new version, which is removed before the read, so the
rows are read from the old version. The test fails without the check.

Address review: ClickHouse#115724 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…llision-114847

Master moved `parallel_inserts` from the table metadata to a storage member: `runsParallelInserts`
now takes that member. The PR's `hasClaimedFiles` check is replaced by master's equivalent
`acquired_files` check.
Master points `contrib/aws` at a fork where `Aws::String` uses `Aws::Allocator`, so it no longer
converts implicitly to and from `String`. Convert explicitly where the PR passes values between them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… per row

`One` reads no bytes, so its reader reports no generation and the per-chunk check was skipped. On an
unversioned bucket a rewrite between the claim and the tag lookup emitted the claimed `_etag`/`_size`
with the tags of the new object. Fall back to the generation recorded for the file (claimed or listed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 6 commits November 20, 2026 05:26
…versioned objects

`GetObjectTagging` returns the tags of the current object and reports no `ETag`.
Without versions, a rewrite between the `HeadObject` of a tag lookup and
`GetObjectTagging` returned the tags of the new object labelled with the
generation described by `HeadObject`, so `One` on an unversioned bucket could
still emit the claimed `_etag` / `_size` together with the tags of the rewritten
object.

`HeadObject` is now repeated after `GetObjectTagging` when the versions cannot be
compared, and a different `ETag`, `Last-Modified` or version throws
`S3_OBJECT_CHANGED_DURING_READ`, which resets the file so that the next poll
ingests the rewritten object with its own tags.

Regression test: `test_tags_of_the_generation_rewritten_between_head_and_tagging_unversioned`,
which pauses at the new failpoint `s3_pause_between_head_object_and_get_object_tagging`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A prefixless `after_processing_move_uri` pointing at the source bucket, with
other move keys, maps every object onto its own key. The other keys disable the
native copy, so the buffered copy re-uploaded the same bytes (keeping the `ETag`)
and the `If-Match` delete that followed removed the only copy, while the move was
counted as successful.

The external S3 move now compares the destination bucket and endpoint with the
source (failing closed: endpoints are taken as different only when they are known
to be) and the key, and leaves an object that would be moved onto itself in place
with an error and `ObjectStorageQueueMoveCollisions`, like a collision. The same
check is applied to moves within the bucket (a flattening prefix can map `a/x` to
itself) and to Azure moves (compared by blob URL).

Regression test: `test_external_move_onto_the_source_itself_is_refused`; without
the check the object is copied onto itself and removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…endpoint

The self-move check compared the endpoints of the source and the move
destination, and took two endpoints with different hosts or ports as two
independent services. That is not proven: `http://minio1:9001` and the IP
address of the same container (or a CNAME, a private endpoint) name the same
bucket. With a prefixless move to such an alias, the buffered copy re-uploaded
the object onto itself and then deleted the only copy.

A move whose destination bucket has the source bucket's name and whose key is
the source key is now always refused, and an Azure move is compared by the
blob path only (container and blob name, and the account for path-style
endpoints). The regression test `test_external_move_onto_the_source_itself_is_refused`
now also runs with the move URI pointing at the MinIO IP address.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s point

An S3 access point alias (`...-s3alias`), an Object Lambda alias (`...--ol-s3`),
an access point or Object Lambda host and a Multi-Region Access Point host all
address the objects of a bucket whose name they do not contain. A comparison of
bucket names cannot prove that such a destination is distinct from the source, so
a prefixless external move that keeps the key is refused as a self-move whenever
either side is addressed through an access point.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…master`

The merge of `master` brought a new call of `isSettingChangeable` in
`StorageObjectStorageQueue::alter` (the `differs_from_queue` lambda), while
this branch added the `storage_type` argument to that function, so the merged
tree did not compile.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
valerypetrov and others added 5 commits November 22, 2026 13:13
…llision-114847

Conflicts:
- `S3ObjectStorage::tryGetObjectMetadata`: `master` made it describe the version selected
  by `?versionId=`. It now passes `uri.version_id` to `tryGetObjectVersionMetadata`, which
  keeps taking the version from its caller.
- `createReadBuffer` in `StorageObjectStorageSource.cpp`: the bypass of the caches for a
  read pinned to an S3 version is kept next to the new page cache check for `Web` objects,
  and the read is pinned to the `ETag` also when the page cache requires it
  (`pin_read_to_etag_for_page_cache`), in addition to `require_read_pinned_to_generation`.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… source URL

`S3ObjectStorage::tryGetObjectMetadata` now describes the version selected by `?versionId=`
of the storage URL (after the merge of `master`). The move within a bucket used it to look
at the destination after a refused guarded copy, to recognise its own committed copy. A
destination never has the version of the source, so with such a URL the lookup would find
nothing and the copy would be reported as a collision. The destination is now looked up
as the current version of its key.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Address review: an unguarded move (`after_processing_move_preserve_path = 1`, or a prefixless
external move) to another endpoint, or with other valid keys, cannot use `CopyObject` and uploads
the object again. It passed neither the user metadata nor the headers of the source, and it skipped
the tags even with `after_processing_move_preserve_tags = 1`, so the moved object lost its
`Content-Type`, user metadata and tags, and the source was removed.

Every move that uploads the object again now restates the user metadata and the headers, and the
tags when `after_processing_move_preserve_tags` is enabled. An unguarded native copy still passes
nothing, so `CopyObject` keeps `MetadataDirective::COPY`.

`test_buffered_move_with_other_keys_preserves_s3_properties` covers a preserved-path external move
with distinct valid destination keys.

ClickHouse#115724 (comment)

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…_format_consumed`

Address review: the prefetch is submitted when the read buffer is created, before the tags are
fetched. A delayed prefetch could read the temporary new version between its upload and its
deletion. Its bytes and its tags belong together, so the row was accepted, the original version
stayed, and the test timed out.

The object is now consumed by `INSERT ... SELECT` with `commit_on_select = 1` and
`remote_filesystem_read_prefetch = 0`, so the first byte is requested only after both failpoints.
The test also checks that the first read returned no rows and left the version in place. It runs on
the instance without the keeper fault injection, because a query does not retry a failed commit.

ClickHouse#115724 (comment)

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ge of `master`

`test_failed_lookup_of_the_selected_version_keeps_the_ordered_position` relied on a second key,
`b.csv`, being consumed by the `One` format although the version selected by the URL was not one of
its versions. Since the merge of `master`, `S3ObjectStorage::getObjectMetadata` requests the
selected version, so the reader of `b.csv` gets a 404, the insert fails, and `a.csv` is never
committed.

A version belongs to one key, so no other key can be consumed through such a URL, and no later key
can move the ordered pointer. The test keeps only the selected object and checks that the released
file is read by a later poll. It is renamed to
`test_failed_lookup_of_the_selected_version_releases_the_file`.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115724&sha=93de7aac44c4be7a9373ac3daa3feaa78f10ab29&name_0=PR&name_1=Integration%20tests%20(amd_asan_ubsan%2C%20db%20disk%2C%20targeted)
ClickHouse#115724

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Pushed three commits on top of 93de7aa; the branch is current with master.

  • CI failure (test_failed_lookup_of_the_selected_version_keeps_the_ordered_position, report): caused by the merge of master, where S3ObjectStorage::getObjectMetadata now requests the version selected by ?versionId=. The test's second key b.csv does not have that version, so its reader got a 404, the insert failed, and a.csv was never committed. 6f88801 keeps only the selected object and renames the test to test_failed_lookup_of_the_selected_version_releases_the_file. It no longer checks the ordered pointer, because no other key can be consumed through such a URL.
  • Buffered moves losing metadata, headers and tags: fixed in d8650b1, with a new regression test.
  • Prefetch race in test_tags_of_the_version_a_byte_reading_format_consumed: fixed in 256e2d1.

Both review threads are answered and resolved, so the full CI suite can run. The remaining failure on the previous head was the review-thread gate itself.

One thing for the author or a maintainer to judge: a key that lacks the selected version still fails the whole batch in createReader on every poll, and with s3queue_loading_retries = 0 the files read before it in that batch are marked failed. This is the master behaviour for a glob URL with versionId, so I left it out of this PR.

…t names

The previous commit renamed `test_failed_lookup_of_the_selected_version_keeps_the_ordered_position`
to `test_failed_lookup_of_the_selected_version_releases_the_file`, which is the name of the test
right above it. The second definition shadowed the first one, so the first test was not collected,
and the `ruff` check of the Style check failed with `F811 Redefinition of unused
test_failed_lookup_of_the_selected_version_releases_the_file`, which dropped the rest of the CI.

The test of the ordered queue is now
`test_failed_lookup_of_the_selected_version_releases_the_file_of_an_ordered_queue`.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115724&sha=6f888019baaa049ea9a74a5aba8beae45ca7a782&name_0=PR&name_1=Style%20check
ClickHouse#115724

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Pushed d9027b9: the only CI failure on 6f88801 was the ruff check of the Style check (F811 Redefinition of unused test_failed_lookup_of_the_selected_version_releases_the_file), which dropped the rest of the CI, including the bugfix validation. The rename in 6f88801 gave the test of the ordered queue the name of the test right above it, so the first one was shadowed. The second is now test_failed_lookup_of_the_selected_version_releases_the_file_of_an_ordered_queue; ruff check passes on the Python files of this PR. There are no unresolved review threads.

alexey-milovidov and others added 2 commits November 23, 2026 12:31
…es the object anew

Only `CopyObject` carries the user metadata, the headers and the tags of the
source for free. The post-processor guessed which moves take another route
(a guarded one, or one with the native copy disabled for the external
destination) and passed the properties only then. The guess missed the moves
whose route is decided inside `copyS3File`:

- a move within the storage with `after_processing_move_preserve_path = 1`
  and `allow_native_copy = 0` configured for the endpoint, which uploads the
  object again;
- a file above `max_single_operation_copy_size`, which is copied by parts
  into a new `CreateMultipartUpload`;
- a fallback from a refused `CopyObject`.

Such a move replaced `Content-Type` with `binary/octet-stream`, dropped the
user metadata and the tags, and removed the source.

The decision now belongs to `copyS3File`. `S3CopyFileSettings` gets
`source_metadata` and `source_tags_reader` next to `source_headers`; they are
applied on `PutObject` and `CreateMultipartUpload` and never on `CopyObject`,
which keeps `MetadataDirective::COPY`. The tags of an unguarded move are read
lazily, so a plain `CopyObject` costs no `GetObjectTagging`. Every move hands
the properties over: the external one directly, and the one within the
storage through the new `WriteSettings::object_storage_copy_preserve_source_properties`,
so other callers of `S3ObjectStorage::copyObject` are unchanged.

`test_unguarded_move_without_copy_object_preserves_s3_properties` covers a
preserved-path move within the storage with the native copy disabled and with
a multipart copy, with source metadata, a nondefault `Content-Type` and tag
preservation enabled.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The `after_processing` action lives in the Keeper metadata, which is shared
by every table of a Keeper path, while the move destination belongs to each
table. `after_processing_publication_mutex` makes the pair coherent only for
the table being altered. Another table of the same Keeper path can keep an
incomplete destination (only `after_processing_move_uri`, without the keys),
which is valid for `keep`. Once the first table is altered to `move`, the
second one read and inserted its files, failed to move them with
`BAD_ARGUMENTS` before the Keeper commit, and inserted the rows again on
every poll.

`createSource` now runs the same completeness check as `CREATE` and `ALTER`
(extracted to `checkMoveDestinationIsComplete`), plus the check that the
destination fits the storage type, whenever the batch captured `MOVE`. An
incomplete destination fails the batch before it claims any file, with a
message naming the table, until the table gets a destination of its own.

`test_move_action_set_through_another_table_of_the_keeper_path` covers the
action change through a second local table sharing the Keeper path.

The test completes the destination with an `ALTER`, which printed the value
of `after_processing_move_secret_access_key` in the `New setting` trace line
of `alter`. The value of that setting and of
`after_processing_move_connection_string` is no longer logged there.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-s3queue S3Queue/AzureQueue engines (queue-based ingestion from object storage). external Author is not a member of the ClickHouse organization pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S3Queue after_processing='move' silently destroys a consumed file on a basename collision (default move_preserve_path=false)

6 participants