Skip to content

Check s3_min_upload_part_size also when s3_strict_upload_part_size is set - #129747

Merged
PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/s3-strict-keep-min-upload-part-size-checks
Nov 6, 2026
Merged

PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/s3-strict-keep-min-upload-part-size-checks

Conversation

@groeneai

@groeneai groeneai commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #129578
Related: #103394

Changelog category (leave one):

  • Improvement

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

With s3_strict_upload_part_size set, an S3 disk, an s3 query or an S3 backup whose s3_min_upload_part_size is zero or greater than s3_max_upload_part_size is now rejected up front with INVALID_SETTING_VALUE, as Azure already does. Before, such a configuration was accepted and a native copy (for example a BACKUP to S3 or a copy between S3 disks) failed later with INVALID_CONFIG_PARAMETER. To keep such a configuration working, set s3_min_upload_part_size to a non-zero value not greater than s3_max_upload_part_size.

Description

Follow-up requested in #129578 (comment).

S3RequestSettings::validateUploadSettings checks min_upload_part_size (not zero, not above max_upload_part_size) only when strict_upload_part_size is 0. Writes with a strict size never read the min, but copyS3File ignores the strict size and splits by min and max in calculatePartSize, which throws INVALID_CONFIG_PARAMETER. On master, with s3_strict_upload_part_size = 1048576 and s3_max_single_part_upload_size = 1024 (forces a multipart copy), s3() writes are accepted and BACKUP TABLE ... TO S3(...) fails with:

  • s3_min_upload_part_size = 0: Code: 318 ... min_upload_part_size must not be 0;
  • s3_max_upload_part_size = 1048576, s3_min_upload_part_size = 16777216: Code: 318 ... max_upload_part_size must not be less than min_upload_part_size.

The two checks now run in both modes, as in Azure's RequestSettings::validateUploadSettings. Only the multiply-factor checks stay strict-only, and nothing changes when no strict size is set.

Category Improvement: the only symptom on released versions is a late, clear error from a contradictory configuration.

Behaviour change: such settings are now rejected when the disk, the s3() query or the backup is set up. A server whose config has such an S3 disk no longer starts, as master already does for the same values without a strict size.

Test: extends 05508. Its three existing statements gain s3_min_upload_part_size = 1048576, because the default 16 MiB min is now rejected with a 1 MiB max. Each new check has its own failing case. 50/50 with randomized settings.

Not changed: settings are still validated per <s3> endpoint layer (#129670).


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

Version info

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

… 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]>
@groeneai

groeneai commented Nov 6, 2026

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 review (2 nits).

# Sev Finding Verdict Evidence / action
1 ❌ Per-layer validation: an intermediate layer (<s3> + query settings) is validated before the endpoint override, so with a strict size a config whose merged settings are valid can now be rejected; a reload merges valid layers without validating the result DISAGREE (separate PR) Validation placement in the callers, the same for non-strict settings on master. #129670 validates only the merged settings and the reload result; no file overlap, so the two compose in either merge order.
2 💡 Behaviour-change sentence names only server-config disks DISAGREE Same checks already throw for these values without a strict size, and #129578 does the same for strict > max.
3 💡 "as Azure already does" DISAGREE Refers to the check set in Azure's RequestSettings::validateUploadSettings.

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

Session id: cron:clickhouse-review-slot-10:20261106-142900

@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. On master 1f96853a2a9c, BACKUP TABLE r TO S3(s3_conn, ...) SETTINGS s3_strict_upload_part_size = 1048576, s3_max_single_part_upload_size = 1024 with s3_min_upload_part_size = 0 fails every run with Code: 318 min_upload_part_size must not be 0, and with max = 1 MiB, min = 16 MiB with Code: 318 max_upload_part_size must not be less than min_upload_part_size; the same settings are accepted for s3() writes.
b Root cause explained? S3RequestSettings::validateUploadSettings ran the two min checks only under if (!strict_upload_part_size). Strict-mode writes never read the min, but copyS3File ignores the strict size and checks min and max again in calculatePartSize.
c Fix matches root cause? Yes. The two checks move out of the strict branch, as in Azure's validator (#103394); only the multiply-factor checks stay strict-only.
d Test intent preserved / new tests added? 05508 extended with five rejections (S3 disk, s3(), BACKUP). Its three existing statements gain s3_min_upload_part_size = 1048576; removing #129578's strict > max check still fails exactly those two strict > max cases.
e Both directions demonstrated? Yes. 05508 fails on master and passes with the fix; moving either check back under the strict branch fails only that check's statements.
f Fix is general across code paths? Yes. Every validating constructor and updateFromSettings funnels into this function (disk config and reload, s3()/S3 engine/named collections, BACKUP/RESTORE, endpoint sections). Azure already holds; calculatePartSize keeps its runtime check for s3_validate_request_settings = 0.
g Fix generalizes across inputs (params/datatypes/wrappers)? min = 0, min > max and min == max (accepted) are covered; a BACKUP plus RESTORE with strict = max = min = 1 MiB through the multipart path succeeds. The settings are UInt64, so type wrappers do not apply.
h Backward compatible? (maintainer-approved exception only) Requested by the maintainer: such configs are now rejected up front, including at server startup for a configured disk (as master already does without a strict size). No default changes. The changelog entry names the workaround.
i Invariants and contracts preserved? The validator now requires min > 0 and min <= max whatever the strict size. With no strict size the checks and their order are unchanged.

Session id: cron:clickhouse-impl-slot-40:20261106-134300

@clickhouse-gh

clickhouse-gh Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e40ee1e]

Summary: ✅


AI Review

Summary

PR #129747, reviewed at e40ee1e790f4a4ec167e83a1682144f8df3bdbdd, makes S3RequestSettings::validateUploadSettings reject zero minimum upload sizes and minimum sizes above the maximum even when a strict size is configured. The focused stateless regression coverage matches this change. No new actionable findings; the author’s decision to handle settings-layer validation separately in PR #129670 is accepted.

Missing context / blind spots
  • ⚠️ Runtime results were not independently verified: this checkout has no ClickHouse binary, and the CI report helper returned no per-test result for 05508_s3_strict_upload_part_size_above_max. The author reports 50 successful randomized runs; a completed CI result for this test would close the verification gap.
Final Verdict

✅ Approve — no new inline findings or required changes.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Nov 6, 2026
@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

cc @alesapin @scanhex12, could you review this and add the can be tested label so CI runs? With s3_strict_upload_part_size set, S3RequestSettings::validateUploadSettings skipped the min_upload_part_size checks that copyS3File still relies on in calculatePartSize, so a contradictory config was accepted and a later BACKUP to S3 failed with INVALID_CONFIG_PARAMETER; the checks now run in both modes, as in the Azure validator.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Nov 6, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. label Nov 6, 2026
@PedroTadim PedroTadim self-assigned this Nov 6, 2026
@PedroTadim
PedroTadim enabled auto-merge November 6, 2026 16:03
@clickhouse-gh

clickhouse-gh Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing e40ee1e79 with master fa154b8c5 (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.

Compile time of recompiled translation units

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

Job report

@PedroTadim
PedroTadim added this pull request to the merge queue Nov 6, 2026
Merged via the queue into ClickHouse:master with commit c4912ea Nov 6, 2026
366 of 368 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 6, 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-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. pr-improvement Pull request with some product improvements 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