Skip to content

Cherry pick #119238 to 26.3: Don't use backoffs on concurrent inserts conflicts - #119416

Merged
robot-clickhouse-ci-2 merged 4 commits into
backport/26.3/119238from
cherrypick/26.3/119238
Sep 17, 2026
Merged

robot-clickhouse-ci-2 merged 4 commits into
backport/26.3/119238from
cherrypick/26.3/119238

Conversation

@robot-clickhouse-ci-2

Copy link
Copy Markdown
Contributor

Original pull-request #119238

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

scanhex12 and others added 3 commits September 10, 2026 14:12
`409 Conflict` reports that a request conflicts with the current state of the
target resource, so resending the same bytes cannot succeed - only the caller,
after re-reading that state, can build a request that does.

It was classified as retriable, so `ReadWriteBufferFromHTTP::doWithRetries`
resent the byte-identical request `http_max_tries` (10) times with a growing
backoff before handing the error back. An Iceberg REST catalog commit is the
worst case: it carries an `assert-ref-snapshot-id` requirement naming a parent
snapshot that a concurrent writer has already replaced, so all 10 attempts are
refused by construction, and every logical commit conflict cost ~32 seconds of
`sleepForMilliseconds`. `IcebergStorageSink` already handles the refusal
properly - `RestCatalog::updateMetadata` returns `false`, the sink re-reads the
branch tip and rebuilds the commit - so the retries only delayed the answer it
was waiting for.

Measured against a mock server counting requests: one `409` cost 10 requests
and 32.9 seconds before, and 1 request and 0.19 seconds after.

Forcing `http_max_tries = 1` for catalog commits instead would also drop the
retries of genuinely transient failures, which the sink's own loop does not
recover from: it treats only `409` as retriable and throws on anything else.

Tests: `05055_http_conflict_is_not_retried` pins the transport behaviour, and
`test_catalog_commit_conflict_reaches_caller_at_once` pins it for a catalog
commit, where a single `INSERT` with `max_insert_threads = 4` makes the conflict
a property of the plan rather than a race - every sink reads the branch tip in
its constructor, and all of them are constructed before the pipeline starts.
The latter fails with `assert 10 == 1` without this change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Don't use backoffs on concurrent inserts conflicts
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 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 Sep 11, 2026
@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Sep 11, 2026
@maxknv maxknv removed the external Author is not a member of the ClickHouse organization label Sep 11, 2026
@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor

Dear @diegomestre2, @scanhex12, this cherry-pick PR has not been updated for 3d0h7m24s. Please resolve the conflicts to backport #119238, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity.

@diegomestre2

Copy link
Copy Markdown
Contributor

@oranjeai check the changes and merge are correct

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.

5 participants