Repository navigation
Reject s3_strict_upload_part_size greater than s3_max_upload_part_size - #129578
PedroTadim merged 4 commits into
Conversation
S3RequestSettings::validateUploadSettings ran every part-size check under `if (!strict_upload_part_size)`, so a non-zero strict size was never compared with max_upload_part_size. A strict size selects FixedSizeBufferAllocationPolicy, so WriteBufferFromS3 fills buffers of up to strict bytes; a write larger than max_single_part_upload_size goes multipart and writePart throws the LOGICAL_ERROR "Part size exceeded max_upload_part_size" on the first part (La Casa Del Dolor (amd_debug), STID 2991-407b: strict 83 MiB, max 16 MiB). Mirror the Azure check (cc4b9fe, ClickHouse#103394): reject strict > max with INVALID_SETTING_VALUE in both modes. Every S3 request-settings entry point goes through this function (disk creation, config reload, <s3> sections, s3() and S3 engine query settings, query overrides on an S3 disk, BACKUP/RESTORE), so such a configuration now fails up front instead of on the first large write. La Casa Del Dolor drew s3_strict_upload_part_size up to 100 MiB against a 16 MiB floor for s3_max_upload_part_size (15.32% strict > max in direct draws, 3.83% of generated S3 disks). Cap it at 16 MiB with bits=24, as ClickHouse#128857 did for Azure, so the new check does not stop Dolor servers from starting. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop a comment that restates the new check's error message. 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; 1 finding) plus my own cold review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261105-183400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261105-175400 |
|
cc @PedroTadim @Michicosun, could you review this? S3 request-settings validation compared part sizes only when |
|
Workflow [PR], commit [dc2069f] Summary: ❌
AI ReviewSummaryPR #129578, reviewed at Missing context / blind spots
Findings
Tests
Final VerdictStatus: |
| ErrorCodes::INVALID_SETTING_VALUE, | ||
| "Setting max_part_number cannot be zero"); | ||
|
|
||
| if ((*this)[S3RequestSetting::strict_upload_part_size] > (*this)[S3RequestSetting::max_upload_part_size]) |
There was a problem hiding this comment.
BackupReaderS3 and BackupWriterS3 call S3Settings::loadFromConfig before merging endpoint settings (src/Backups/BackupIO_S3.cpp:398 and :537). The request-settings constructor used there fills missing config fields from query settings and immediately calls this validator.
For example, configure global <s3><max_upload_part_size>16777216</max_upload_part_size>…</s3>, give the matching endpoint max_upload_part_size = 67108864, and run BACKUP or RESTORE with SETTINGS s3_strict_upload_part_size = 33554432. This new check throws on the temporary 32 MiB strict / 16 MiB maximum pair before the endpoint's 64 MiB maximum is merged. The effective 32 MiB / 64 MiB configuration is valid and was accepted before this change, so legitimate backups and restores now fail.
Defer validation of these intermediate settings until endpoint and query overrides have been applied, retain validation of the final settings in both backup paths, and add a regression for this layered configuration.
|
🕵️ @groeneai The new check and the Dolor cap look right. With The
A one-line fix covers all three: throw The bot's other finding holds too, in the opposite direction: validating each layer separately can reject an endpoint override that would make the merged settings valid. But the existing |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 9 s compile time in total, 7 of them have a recent master baseline. |
WriteBufferFromS3::writePart threw LOGICAL_ERROR when a part was larger than max_upload_part_size. That state is reachable from configuration, not only from a bug: with s3_validate_request_settings = 0, or after a config reload that merges an S3 disk section with an endpoint section without validating the result. A strict_upload_part_size above max_upload_part_size then aborted debug and sanitizer builds on the first multipart part. Throw INVALID_CONFIG_PARAMETER instead, as the max_part_number check right above already does. The up-front check in validateUploadSettings stays as the error at configuration time. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Done in c083ee2: I'll send validation of the merged settings as a separate PR. The per-layer check also hits plain |
|
Validation of the merged S3 request settings is in #129670. |
This reverts commit c083ee2. The strict > max check in validateUploadSettings is what fixes the CI failure, so this PR does not need to change the error code in WriteBufferFromS3::writePart. The s3_validate_request_settings = 0 case of the test goes with it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - dc2069fEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261106-123005 |
|
🕵️ @groeneai For a follow-up PR: with a strict size set,
|
|
The CI failure is unrelated |
|
Acknowledged. I'm investigating moving the two |
1f96853
|
Opened the follow-up: #129747. The two |
… set S3RequestSettings::validateUploadSettings ran the "min_upload_part_size cannot be zero" and "max_upload_part_size can't be less than min_upload_part_size" checks only when no strict part size was set. Writes with a strict size use fixed-size parts and never read the min, but copyS3File / copyDataToS3File ignore the strict size and split by min and max in calculatePartSize. So such a configuration was accepted, and a native copy (a BACKUP to S3, a copy between S3 disks) failed later with INVALID_CONFIG_PARAMETER. Run both checks in both modes, as Azure's RequestSettings::validateUploadSettings already does (ClickHouse#103394). Only the multiply-factor checks stay strict-only; without a strict size nothing changes. Test 05508: the three existing statements set s3_min_upload_part_size to 1 MiB, since the default 16 MiB min is now rejected with a 1 MiB max; this also keeps the strict > max cases testing only that check. New cases: an S3 disk and s3() for each check, and a BACKUP. Requested in ClickHouse#129578 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #103394
Related: #128857
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
An S3 disk or query whose
s3_strict_upload_part_sizeis greater thans3_max_upload_part_sizeis now rejected up front withINVALID_SETTING_VALUE, as Azure already does. Before, such a configuration was accepted and every write larger thanmax(s3_max_single_part_upload_size, s3_max_upload_part_size)failed with the logical errorPart size exceeded max_upload_part_size. To keep such a configuration working, lowers3_strict_upload_part_sizeor raises3_max_upload_part_size.Description
La Casa Del Dolor (amd_debug) hit
Logical error: 'Part size exceeded max_upload_part_size ... part size 29304992, max_upload_part_size 16777216'inWriteBufferFromS3::writePart. The S3 disk hads3_strict_upload_part_size83 MiB ands3_max_upload_part_size16 MiB.S3RequestSettings::validateUploadSettingsruns every part-size check underif (!strict_upload_part_size), so strict is never compared with max. A non-zero strict size selects fixed-size buffers, a write larger thanmax_single_part_upload_sizegoes multipart, and its first part exceeds max. The Azure version rejects this (#103394). The check now runs in both modes, before the S3 client is built.The Dolor generator draws
s3_strict_upload_part_sizeup to 100 MiB against a 16 MiB floor for max. It is now capped at 16 MiB (bits=24), as #128857 did for Azure; without that, the new check would stop such a server from starting.Category
Improvement: the only symptom on released versions is a late logical error from a contradictory configuration.Validation: the new test fails on master, passes 50/50 with randomized settings, and flipping
>to>=breaks itsstrict == maxcase. A 3 MB write with strict 2 MiB and max 1 MiB aborts the old binary throughs3()and through an S3 disk. Generator: 15.32% strict > max in 1M draws before, 0 after.Not changed: with strict set, S3 still skips its
min_upload_part_sizechecks, and settings are still validated per layer, so a layered config whose merged settings are valid can be rejected (#129670). Withs3_validate_request_settings = 0the logical error inwritePartstays reachable. #128707 (open) edits the sameproperties.pyline.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/129578]
Version info
26.11.1.1521-master(included in26.11and later)