Skip to content

Stop retrying S3 reads after query cancellation - #114497

Open
ilejn wants to merge 3 commits into
ClickHouse:masterfrom
ilejn:stop_retry_s3_reads
Open

ilejn wants to merge 3 commits into
ClickHouse:masterfrom
ilejn:stop_retry_s3_reads

Conversation

@ilejn

@ilejn ilejn commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Improvement

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

Stop retrying S3 reads after query cancellation


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

filimonov and others added 3 commits August 11, 2026 22:56
processException kept retrying transient errors after KILL QUERY; check
CurrentThread::get().isQueryCanceled() in the outer retry loop.

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: Mikhail Filimonov <[email protected]>
@ilejn
ilejn marked this pull request as ready for review August 19, 2026 20:09
@Ergus Ergus added the can be tested Allows running workflows for external contributors label Aug 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [535c149]

Summary: ❌

job_name test_name status info comment
Stress test (arm_tsan) FAIL
Logical error: Invalid number of columns in chunk pushed to OutputPort. Expected A, found B (STID: 2270-2caa) FAIL cidb

AI Review

Summary

This PR changes ReadBufferFromS3 so a cancelled query stops the outer retry loop instead of continuing to retry a broken S3 stream, and it adds an integration test around a mocked truncated response. The C++ change looks directionally right, but the new regression only proves the processException() cancellation override and does not yet cover the full retry surface the patch changes.

PR Metadata
  • Changelog category: Improvement is too weak for a user-visible cancellation bug in existing S3 reads. Bug Fix matches the change better.
  • Changelog entry: required under Bug Fix, and the current text is specific and user-readable enough once the category is corrected.
Tests
  • ⚠️ [tests/integration/test_storage_s3/test_cancel_during_stream_retry.py:118] The new test pauses inside processException() before the cancellation check, so it validates the throw at src/IO/ReadBufferFromS3.cpp:366 but not the newly added post-sleep checks at lines 228 and 340, nor the separate readBigAt() retry loop. A kill that lands after processException() has already decided to retry still depends on those paths to suppress the extra GetObject. Please add a focused regression for cancel-during-backoff, or a second case that drives a readBigAt() consumer such as Parquet or Arrow.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions: add regression coverage for the backoff-window / readBigAt() retry path.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.90% 86.90% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 79.10% 79.10% +0.00%

Changed lines: Changed C/C++ lines covered: 15/19 (78.95%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Aug 23, 2026
assert get_requests == 1

control("release")
instance.query(f"SYSTEM WAIT FAILPOINT {FAILPOINT} PAUSE", timeout=60)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test kills the query only after SYSTEM WAIT FAILPOINT ... PAUSE, i.e. while ReadBufferFromS3::processException() is stopped before its cancellation check. That proves the new checkIfNotCancelled() at src/IO/ReadBufferFromS3.cpp:366, but it never exercises the new backoff-window checks at lines 228 and 340 or the separate readBigAt() retry loop. A kill that lands after processException() has already decided to retry still relies on those paths to avoid the extra GetObject, so the PR's contract is only partially covered.

Please add a focused regression that cancels while the retry loop is between attempts, or a second case that drives a readBigAt() consumer such as Parquet or Arrow.

@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 535c14938 with master caccecd78 (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
Binary Master PR Δ
programs/clickhouse-stripped 703.83 MiB 700.79 MiB -3.04 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

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

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. label Sep 4, 2026
@maxknv maxknv added the external Author is not a member of the ClickHouse organization label Nov 2, 2026

This branch has not been deployed

No deployments
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. external Author is not a member of the ClickHouse organization pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants