Skip to content

Send Expect: 100-continue for large S3 request bodies - #130514

Closed
CheSema wants to merge 10 commits into
masterfrom
s3-expect-100-continue
Closed

CheSema wants to merge 10 commits into
masterfrom
s3-expect-100-continue

Conversation

@CheSema

@CheSema CheSema commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Related: #124326
Related: #124557

ClickHouse sent the whole request body before it read any response. When a server rejects a request on its headers and closes the connection (MinIO for an expired multipart upload), the answer was lost and the error was retried as a network error. #124557 read that early answer, but only over plain HTTP.

Now a body of at least s3_expect_continue_min_body_size (256 KiB, the size above which Go servers stop draining) waits up to s3_expect_continue_timeout_ms for 100 Continue. A final response skips the body, 417 resends the request without the header, and no answer sends the body. This works over HTTP and HTTPS, so the #124557 workaround is removed. Not checked: how GCS, R2 and proxies answer Expect; a server that never answers costs up to the timeout per upload.

Changelog category (leave one):

  • Improvement

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

S3 requests with a body of at least s3_expect_continue_min_body_size bytes (256 KiB by default) now send Expect: 100-continue, so an error that the server sends before it reads the body, such as NoSuchUpload for an expired multipart upload, is reported over HTTP and HTTPS instead of being retried as a network error. Set s3_expect_continue_min_body_size = 0 to disable it.


With compatibility set to 26.10 or older, the header is off, and the plain-HTTP early-response read from #124557 no longer exists.

🤖 Generated with Claude Code


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

A server that rejects a request on its headers (MinIO for an expired
multipart upload) answers before reading the body and resets the
connection; over TLS that answer was lost and the error was retried
as a network error. Bodies of at least `s3_expect_continue_min_body_size`
now wait for `100 Continue` and skip the body on a final response.
On `417 Expectation Failed` the request is sent once more without the
header, without using up a redirect. Tests cover a server that never
sends `100 Continue`, one that sends it late, and one that answers 417.
`Expect: 100-continue` now gets an early error response over HTTP and
HTTPS, so the plain-HTTP-only workaround from #124557
(`receiveEarlyResponse`, `receiveEarlyHTTPResponse`) is not needed.
The TLS layer reads with the larger of the receive and send timeouts,
so the wait lasted up to the send timeout (30 s); set both. A zero
`s3_expect_continue_timeout_ms` waited forever; it now disables the
header.
@clickhouse-gh

clickhouse-gh Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2e6fda7]

Summary: ❌

job_name test_name status info comment
Integration tests (arm_binary, 3/4) FAIL
test_backward_compatibility/test_aggregate_function_state_tuple_return_type.py::test_backward_compatibility_for_tuple_return_type FAIL cidb

AI Review

Summary

Adds Expect: 100-continue for large S3 request bodies, handles early responses over HTTP and HTTPS, and retries 417 without the expectation. Request changes: existing S3 tables can ignore the new query-level opt-out, timeout, and compatibility settings.

Missing context / blind spots
  • ⚠️ Runtime validation was not performed locally because no ClickHouse binary or build is available. The targeted integration report for head 2e6fda76ce0280de8bd7a64f544b6f6d32e0f58d has no completed test results; completed targeted jobs would close this gap.
Findings

⚠️ Majors

  • src/Disks/DiskObjectStorage/ObjectStorages/S3/diskSettings.cpp:155–160: Existing S3 table clients ignore expectation overrides. A table created with explicit credentials is static, so subsequent inserts set allow_client_change = false and skip client reconstruction in S3ObjectStorage::applyNewSettings. An insert larger than 256 KiB still sends Expect: 100-continue despite s3_expect_continue_min_body_size = 0 or compatibility = '26.10'; timeout overrides likewise never reach the transport. Honor the effective query settings while preserving the table's resolved credentials.
Tests
  • ⚠️ Extend the existing mock coverage to create a persistent ENGINE = S3 table first, then insert with the explicit opt-out and older compatibility, checking the received Expect header. Current coverage creates a new table-function client for each query and misses the reused-client path.
Final Verdict

Status: ⚠️ Request changes. Honor expectation overrides for existing S3 tables and add the focused regression case.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Nov 10, 2026
A zero socket timeout means no timeout, so the wait would never end.
`s3_expect_continue_min_body_size = 0` is the only way to disable the
header.
Comment thread src/IO/S3/PocoHTTPClient.cpp Resolved
Comment thread src/IO/HTTP/HTTPClientIO.cpp Resolved
…SCOPE_EXIT_SAFE`

Poco `waitForResponseData` now reads with the current socket timeouts;
`waitForHTTPContinue` sets both timeouts and restores them in a guard,
before the response header is read.
@clickhouse-gh clickhouse-gh Bot added the comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. label Nov 10, 2026
@CheSema
CheSema marked this pull request as ready for review November 10, 2026 15:35
Comment thread src/IO/S3RequestSettings.cpp Resolved
@Michicosun Michicosun self-assigned this Nov 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 2e6fda76c with master 2170ef336 (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-keeper ×1.08 (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 DB::registerFunctionConversion(DB::FunctionFactory&) 9.1 s 19.4 s +10.4 s (+115%)
Compile time of recompiled translation units

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

Job report

alexey-milovidov added a commit that referenced this pull request Nov 11, 2026
Drop the early-error-response part (`HTTPClientSession` and `PocoHTTPClient` changes,
the `early` mode of the `no_such_upload` mock and its test): the mock action it extends
comes from #118829, which is not on 26.9, and
#130514 replaces this approach on master with
`Expect: 100-continue`. What remains is fe7dab9 (no outer retry of an error the SDK
has already retried), the same tree as the resolution proposed and tested by groeneai.

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

CheSema commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Closing in favor of #130858. Watching the connection while the body is sent (RFC 9112, section 9.5) reports an early error response over HTTP and HTTPS without Expect: 100-continue, so the extra round trip per upload is not needed.

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

Labels

comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants