Repository navigation
Conversation
While the body is sent, the connection is watched for a response (RFC 9112, 9.5) with non-blocking writes, so an early error such as `NoSuchUpload` is reported instead of `Broken pipe`, also over TLS. Replaces the plain-HTTP-only early-response read of #124557. Setting `s3_monitor_response_while_sending`.
|
Workflow [PR], commit [a7d93f6] Summary: ❌
AI ReviewSummaryThe PR monitors responses while sending HTTP request bodies, using nonblocking writes and an incremental response parser to report early server errors over HTTP and HTTPS. Static review of Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; runtime validation remains subject to the pending CI checks. |
`HTTPRequestBodyWriteBuffer` always watches the connection while it sends the body; an early final response is kept in the session and returned by `receiveHTTPResponse`, which fails closed for a success status. No setting. The non-blocking switch around the send uses `ScopedNonBlocking`, moved out of `SocketPeerClosed.cpp`.
The response is parsed into the session between body chunks: an error status stops the body, a success is finished after it, so an early `200` or streamed headers no longer fail or block the request. The blocking throttle wait goes to the socket that TLS charges, so `max_remote_write_network_bandwidth` holds over HTTPS. Also a deadline across `EINTR`, and no completed chunked request after an early stop.
How to read this PRReview the whole diff, not commit by commit: the early commits contain intermediate designs that the later commits replace. The order below puts the most important parts first.
How it worksA rejected upload over TLS, before and afterThe
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes59 object files changed (+57.01 KiB total), 2 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units417 translation units recompiled, 2775 s compile time in total, 415 of them have a recent master baseline. |
Related: #124326
Related: #124557
Related: #130514
A server can answer a request it rejects before reading the whole body and then close the connection: MinIO does this for
NoSuchUploadon an expired multipart upload, and AWS S3 answers a rejected upload after reading about 10 MB. ClickHouse wrote the whole body first, so the write failed withBroken pipeand the error was retried as a network error. #124557 read that early answer for S3, but only over plain HTTP, because OpenSSL allows no read after a failed write.The change:
Poco::Net::HTTPResponseParser. For the same bytes, it gives the same result and the same exceptions asPoco::Net::HTTPResponse::read, and it checks the header limits as the data arrives. An error status stops the body at once. A2xxis finished after the body. A100 Continueis skipped. The blocking read of a response uses the same parser.sendHTTPRequestcaller (S3, Azure, theurlengine, and others) with no caller change. The header limits are now given tosendHTTPRequest, because the response is parsed while the body is sent; S3 and Azure pass theirs there. This replaces the plain-HTTP-only workaround of Fix nested S3 request retries and read the error an S3 server sends before the whole request body #124557.Known limitation: Silk fiber sockets have no non-blocking mode, so they keep the blocking writes without the watching, and an early response on them is read only after the body. Over plain HTTP they also lose the read after a failed write that #124557 added. A follow-up can add a fiber-aware wait for reading or writing to these sockets.
A reading guide with diagrams: #130858 (comment)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
While sending the body of an HTTP request (S3, Azure, the
urlengine and other HTTP clients), ClickHouse now watches the connection for an early response, so an error that the server sends before it reads the whole body, such asNoSuchUploadfor an expired multipart upload, is reported instead of being retried as a network error, also over TLS.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/130858]