Skip to content

Cherry pick #114975 to 26.3: Use offset in performSinglepartUpload for Azure - #118251

Merged
robot-clickhouse-ci-2 merged 10 commits into
backport/26.3/114975from
cherrypick/26.3/114975
Sep 5, 2026
Merged

robot-clickhouse-ci-2 merged 10 commits into
backport/26.3/114975from
cherrypick/26.3/114975

Conversation

@robot-ch-test-poll

Copy link
Copy Markdown
Contributor

Original pull-request #114975

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-pick locally.
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.

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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

SmitaRKulkarni and others added 9 commits August 15, 2026 23:51
`BackupWriterAzureBlobStorage::copyFileFromDisk` forwards `start_pos` and
`length` into `copyAzureBlobStorageFile`, but the native-copy branch of that
helper calls `CopyFromUri` / `StartCopyFromUri`, which carry no byte range and
always transfer the entire source blob. The requested range was therefore
silently ignored whenever `allow_azure_native_copy` was on, so an incremental
backup could store a whole file where only its tail belongs, and restoring it
would reconstruct the wrong bytes.

Guard the native copy the same way `BackupWriterS3::copyFileFromDisk` does: it
is used only when the request covers the entire source, measured with
`getEncryptedFileSize` for an encrypted source. `start_pos != 0` alone is not a
sound test, because a prefix `[0, length)` of a bigger file is a range too.
Ranged copies fall back to `BackupWriterDefault::copyFileFromDisk`, which reads
through buffers and honors the range.

To make the trap unrepeatable, `copyAzureBlobStorageFile` loses its `src_offset`
parameter: it now copies a whole blob, like `copyS3File`, and callers that need
a range use `copyDataToAzureBlobStorageFile` instead.

The new integration test reaches the native copy with a non-zero `start_pos`. A
`Log` data file on an Azure disk normally gets one object per `INSERT`, and a
multi-object source is already excluded from the native copy, so the table is
truncated and refilled by a single `INSERT` with `max_block_size = 1`: every row
lands in its own compressed block, the first block stays byte-identical to the
one the base backup holds, and the whole file is a single blob.
An Azure disk hands out random blob paths, so by default `BackupFileInfo` takes
the checksum of a file from its remote path (`canCalculateChecksumFromRemotePath`)
and cannot compute a prefix checksum at all, which leaves `base_size` at 0 and
makes every incremental backup copy whole files. The test therefore has to ask
for content checksums with `allow_checksums_from_remote_paths = 0`, otherwise it
never reaches the ranged copy it is meant to cover.

Verified against Azurite with a 26.7 server, which has neither fix: the restored
table comes back with one row instead of two. Disabling the native copy and
forcing the multipart upload -- the offset-correct path in that build -- restores
both rows, which is the route the fix now takes for a ranged copy.
The comment claimed the test reaches the native-copy branch of
`BackupWriterAzureBlobStorage::copyFileFromDisk` with a partial range.
It does not: a `Log` table backs its data files with
`BackupEntryFromAppendOnlyFile`, and `BackupImpl` hands only
immutable-file entries to `copyFileFromDisk`, so the incremental
backup goes through `copyDataToFile`, i.e. the ranged buffered
upload fixed in `performSinglepartUpload`. The whole-object guard in
`copyFileFromDisk` is required because `copyAzureBlobStorageFile`
no longer carries an offset, but no backup entry with a partial
range is dispatched to it today.

Addresses the AI review thread on this test.
Use offset in performSinglepartUpload for Azure
@robot-ch-test-poll robot-ch-test-poll added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-critical-bugfix labels Sep 5, 2026
…ypick/26.3/114975

# Conflicts:
#	tests/integration/test_backup_restore_azure_blob_storage/test.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants