Skip to content

Cherry pick #124557 to 26.8: Fix nested S3 request retries and read the error an S3 server sends before the whole request body - #130424

Merged
robot-clickhouse-ci-1 merged 5 commits into
backport/26.8/124557from
cherrypick/26.8/124557
Nov 11, 2026
Merged

robot-clickhouse-ci-1 merged 5 commits into
backport/26.8/124557from
cherrypick/26.8/124557

Conversation

@robot-clickhouse-ci-1

Copy link
Copy Markdown
Contributor

Original pull-request #124557

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 4 commits October 8, 2026 04:58
`Client::doRequestWithRetryNetworkErrors` retried every retryable error
outcome returned by the AWS SDK, but the SDK's own retry loop has already
run the same `RetryStrategy` with `max_retries = s3_retry_attempts` for it,
so a persistent retryable error was attempted `(s3_retry_attempts + 1)^2`
times (251001 with the default of 500). The outer outcome retry was
introduced in #84854 only for `s3_slow_all_threads_after_retryable_error`,
where the SDK gets `max_retries = 1`; #90216 rewrote the loop and dropped
that condition.

Restore it: with the flag off, a non-success outcome is returned as is.
Exceptions thrown out of the SDK while it reads a response body (the case
#90216 added the loop for) are still retried by the outer loop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…request body

A server may answer a request it rejects right after reading its header and
close the connection with the body unread. MinIO does this for an
`UploadPart` whose multipart upload no longer exists (`404 NoSuchUpload`,
e.g. after its stale-upload expiry). `PocoHTTPClient` writes the whole body
before reading the response, so the write fails with `Broken pipe` or
`Connection reset by peer`; Poco keeps that send error in the session and
`receiveResponse` rethrows it before reading anything, so the 404 is never
seen and the request is retried as a network error until the retry budget
is spent, then fails with the network error instead of `NoSuchUpload`.

When sending the body over plain HTTP fails with a `Poco::IOException` and
response data is already waiting on the socket (non-blocking probe
`getSocketState`), read that response with the new
`HTTPClientSession::receiveEarlyResponse` and use it if its status is an
error (>= 300). Otherwise the send error is rethrown as before. TLS is
excluded: OpenSSL allows no further I/O after a failed `SSL_write`, so over
HTTPS such an error is still retried as a network error (bounded by
`s3_retry_attempts` after the previous commit).

The `no_such_upload` action of the S3 mock gets an `early` mode that
answers without reading the body and resets the connection, as MinIO does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Condense the receiveEarlyResponse doc to its contract and drop the expired-upload example from the PocoHTTPClient catch comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rly-error-response

Fix nested S3 request retries and read the error an S3 server sends before the whole request body
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Nov 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

The conflict is in tests/integration/helpers/s3_mocks/broken_s3.py: the second commit of #124557 extends the no_such_upload mock action that #118829 added on master, and #118829 is not on 26.8. That second commit (reading the error a server sends before the whole request body) is also being replaced on master: #130514 removes it in favour of Expect: 100-continue. So I resolved this cherry-pick with the first commit of #124557 only (fe7dab9, no outer retry of an error the SDK has already retried). Against backport/26.8/124557 the merge changes only src/IO/S3/Client.cpp (+4) and tests/integration/test_checking_s3_blobs_paranoid/test.py (+5), the same patch as fe7dab9.

On the 26.8 tree (clang-22, debug) test_checking_s3_blobs_paranoid passes 36 of 36. Without the Client.cpp change, test_when_error_is_retried fails in all 4 cases: the failing part is attempted (5 + 1)^2 times instead of 5 + 1 (37 S3 errors instead of 7).

I cannot push to cherrypick/26.8/124557. The merge is on my fork and its first parent is this PR's head 4a93e77b61f3, so applying it is a fast-forward:

git fetch https://github.com/groeneai/ClickHouse.git groeneai/resolve-26.8-cherrypick-124557
git push origin FETCH_HEAD:cherrypick/26.8/124557

If 26.8 should get the second commit as well, tell me and I will resolve it with both.

…ypick/26.8/124557

Resolve the conflict in `tests/integration/helpers/s3_mocks/broken_s3.py` by keeping
the PR's `NoSuchUploadAction` and its `no_such_upload` dispatch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robot-clickhouse-ci-1
robot-clickhouse-ci-1 merged commit b4b5297 into backport/26.8/124557 Nov 11, 2026
2 checks passed
@robot-clickhouse-ci-1
robot-clickhouse-ci-1 deleted the cherrypick/26.8/124557 branch November 11, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants