Skip to content

Upload an empty blob in a single part in the Azure read and write copy - #131587

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:azure-copy-empty-blob-single-part
Nov 15, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:azure-copy-empty-blob-single-part

Conversation

@groeneai

@groeneai groeneai commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #94024
Related: #129316

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixed Logical error: Chosen multipart upload for an empty file when an Azure Blob Storage disk with max_single_part_upload_size = 0 copies an empty file, for example on ATTACH TABLE of a permanently detached table in a database stored on a plain_rewritable Azure disk.

Description

On 26.3.60.2, 26.8.34.13 and 26.10.2.103, ATTACH TABLE of a table detached with DETACH TABLE ... PERMANENTLY, in a database on a plain_rewritable Azure disk with max_single_part_upload_size = 0, fails with Code: 49 ... Chosen multipart upload for an empty file. This must not happen, and the table stays permanently detached; debug and sanitizer builds abort. Found by La Casa Del Dolor (amd_msan): fatal.log (report).

Root cause: before removing a file, plain_rewritable copies its blob, and the permanently-detached flag is an empty file. With use_native_copy = 0 (the disk default) the copy reads and writes through UploadHelper::performCopy, which chose the single-part upload only for total_size < max_single_part_upload_size. With the threshold 0 an empty blob went to the multipart path, whose calculatePartSize rejects size 0.

Change: use <=, the rule WriteBufferFromAzureBlobStorage already applies to the same setting and copyS3File applies on S3. An empty blob is now always uploaded in a single part. The only other effect: an object of exactly max_single_part_upload_size bytes is now uploaded with one Put Blob, as the writer already does.

Validation: the new stateless test fails on master (the server aborts) and passes with the fix, 50/50 randomized runs; the same holds for an encrypted disk over cache over the Azure disk. The Azure stateless tests give the same results with and without the fix.


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

Version info

  • Merged into: 26.11.1.2374-master (included in 26.11 and later)

`UploadHelper::performCopy` chose the single-part path only for
`total_size < max_single_part_upload_size`, so with
`max_single_part_upload_size = 0` an empty blob went to the multipart
path, whose `calculatePartSize` rejects size 0 with LOGICAL_ERROR
`Chosen multipart upload for an empty file. This must not happen`.

`plain_rewritable` copies the blob of every file it unlinks, and the flag
of a permanently detached table is an empty file, so `ATTACH TABLE` of
such a table in a database on an Azure `plain_rewritable` disk with
`max_single_part_upload_size = 0` (and `use_native_copy = 0`, the disk
default) failed and left the table permanently detached; debug and
sanitizer builds aborted. Found by La Casa Del Dolor (amd_msan).

Use `<=`, the rule `WriteBufferFromAzureBlobStorage` already applies to
the same setting and `copyS3File` applies on S3. An object of exactly
`max_single_part_upload_size` bytes is now uploaded with one Put Blob,
as the writer already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding) plus my own cold review (1 nit).

# Sev Finding Verdict Evidence / action
1 ⚠️ The test checks that ATTACH succeeds, not that the empty blob is uploaded in one Put Blob DISAGREE The test fails without the fix (server aborts) and passes with it. With the fix, size 0 always takes performSinglepartUpload (copyAzureBlobStorageFile.cpp:157), and the server log shows the copy of the empty t.sql.detached blob running and succeeding. The proposed blob_storage_log check would fail on the fixed code: the same ATTACH writes a non-empty tombstone marker, which goes multipart at threshold 0.
2 💡 The container name has no 63-character guard DISAGREE 50 characters with the runner's database names.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-9:20261114-101400

@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4a29ba2]

Summary: ✅


AI Review

Summary

PR #131587 fixes copying empty Azure blobs when max_single_part_upload_size = 0 by making the single-part upload threshold inclusive. The stateless regression test exercises DETACH TABLE ... PERMANENTLY followed by ATTACH TABLE on an Azure plain_rewritable database disk. No actionable findings in the current diff or surrounding copy paths.

Missing context / blind spots
  • ⚠️ Runtime validation was not independently repeated: this workspace has no ClickHouse binary. The author reports before/after regression runs, including 50 successful randomized runs with the fix. Automated bugfix-validation jobs were dropped following Config Workflow, according to the current CI finish report.
Final Verdict

Status: ✅ Approve. No code changes requested.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default can be tested Allows running workflows for external contributors comp-azure Azure Blob Storage integration (credentials, multipart, Azure-specific IO). labels Nov 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 4a29ba205 with master 71abfbb5c (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.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.60, programs/clickhouse-keeper ×0.63 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse _ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… 3.3 s 7.3 s +5.2 s (+260%)
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 5.7 s 8.6 s +5.1 s (+151%)
Compile time of recompiled translation units

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

Job report

@alexey-milovidov alexey-milovidov self-assigned this Nov 15, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 15, 2026
Merged via the queue into ClickHouse:master with commit 1be838e Nov 15, 2026
604 of 608 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 15, 2026
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-azure Azure Blob Storage integration (credentials, multipart, Azure-specific IO). pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants