Skip to content

Add cancellation check to ObjectStorage read operation - #103016

Merged
SmitaRKulkarni merged 24 commits into
masterfrom
icebergS3Cluster_large_data_fix
Jun 16, 2026
Merged

SmitaRKulkarni merged 24 commits into
masterfrom
icebergS3Cluster_large_data_fix

Conversation

@SmitaRKulkarni

@SmitaRKulkarni SmitaRKulkarni commented Apr 17, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Added cancellation check to ObjectStorage read operation. resolves ##98165

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.6.1.849

@SmitaRKulkarni
SmitaRKulkarni marked this pull request as draft April 17, 2026 14:20
@clickhouse-gh

clickhouse-gh Bot commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6aff536]

Summary: ❌

job_name test_name status info comment
Unit tests (amd_llvm_coverage) FAIL
-FunctionsStress FAIL cidb, issue ISSUE EXISTS
Stress test (arm_ubsan) FAIL
Logical error: Bad cast from type A to B (STID: 4054-600e) FAIL cidb, issue ISSUE CREATED
LLVM Coverage DROPPED IGNORED

AI Review

Summary

This PR adds a post-callback cancellation/time-limit check for object-storage cluster reads, a test failpoint, and an icebergS3Cluster integration test. I do not think it currently satisfies the linked #98165 contract: the unkillable window is still in the blocking read-task callback path, while the new check runs only after that callback returns. I also found one new issue in the added check for timeout_overflow_mode = 'break'.

PR Metadata
  • 💡 Changelog category: Bug Fix is only correct if this PR actually fixes the linked unkillable icebergS3Cluster behavior. With the current code it appears to be a partial timeout check after read-task callback return.
  • 💡 Changelog entry: The current entry, "Added cancellation check to ObjectStorage read operation. resolves #Initiator query remains running and is unkillable when using icebergS3Cluster and underlying tasks have timeout #98165", is implementation-focused and has a malformed issue reference. If the PR is narrowed instead of fixing #98165, use a concrete entry such as: Object-storage cluster table functions now check query cancellation after receiving a read task response, so delayed task assignment respects max_execution_time.
Findings

❌ Blockers

  • [src/QueryPipeline/RemoteQueryExecutor.cpp:561, src/QueryPipeline/RemoteQueryExecutor.cpp:596, src/QueryPipeline/RemoteQueryExecutor.cpp:702, src/QueryPipeline/RemoteQueryExecutor.cpp:910, src/Storages/ObjectStorage/StorageObjectStorageSource.cpp:1601] [dismissed by author -- https://github.com/Add cancellation check to ObjectStorage read operation #103016#discussion_r3399430223] The linked bug promises that an icebergS3Cluster initiator remains killable while read-task callbacks are stuck, but the current code still holds was_cancelled_mutex while processPacket dispatches ReadTaskRequest to processReadTaskRequest, and cancel needs the same mutex before it can send cancel. The new ReadTaskIterator::next check executes only after callback returns, so it cannot interrupt the blocked callback window from #98165. The constructor prefetch path also calls the same callback before any added check. Suggested fix: move the cancellation boundary to the blocking request path itself, or otherwise make read-task callbacks cancellable, and cover it with an asynchronous KILL QUERY ... SYNC regression test.

⚠️ Majors

  • [src/Storages/ObjectStorage/StorageObjectStorageSource.cpp:1602] New inline thread: Add cancellation check to ObjectStorage read operation #103016 (comment). QueryStatus::checkTimeLimit returns false instead of throwing when timeout_overflow_mode = 'break', but the added call ignores the return value. That makes this new timeout boundary ineffective for the supported break mode after a delayed task callback returns. Suggested fix: handle the false result, for example by returning nullptr from the iterator before consuming the returned task.
Tests
  • ⚠️ The integration test only asserts a max_execution_time timeout. It still does not prove the #98165 killability contract: start the INSERT ... SELECT FROM icebergS3Cluster asynchronously with a deterministic query_id, wait for it in system.processes, run KILL QUERY ... SYNC, and assert it disappears before the artificial task delay elapses.
  • ⚠️ Add a focused test for timeout_overflow_mode = 'break' on the delayed object-storage cluster read-task path, since the added checkTimeLimit call has different behavior in that mode.
Final Verdict

Status: ❌ Block

Minimum required actions: handle the checkTimeLimit false return path, and either fix/prove the KILL QUERY behavior from #98165 in this PR or narrow the PR metadata and tests so it no longer claims to close that issue.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Apr 17, 2026
@SmitaRKulkarni SmitaRKulkarni changed the title [WIP]Fix execute query icebergS3Cluster for large data Test insert large data in icebergS3Cluster Apr 20, 2026
@SmitaRKulkarni SmitaRKulkarni changed the title Test insert large data in icebergS3Cluster [WIP] Fix timeout check in icebergS3Cluster Apr 20, 2026
@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog and removed pr-bugfix Pull request with bugfix, not backported by default labels Apr 20, 2026
@SmitaRKulkarni SmitaRKulkarni changed the title [WIP] Fix timeout check in icebergS3Cluster Test icebergS3Cluster to fail for timeout Apr 24, 2026
@SmitaRKulkarni
SmitaRKulkarni marked this pull request as ready for review April 24, 2026 21:15
@alesapin alesapin self-assigned this May 8, 2026

@alesapin alesapin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's add cancellation check as discussed

@SmitaRKulkarni SmitaRKulkarni changed the title Test icebergS3Cluster to fail for timeout Add cancellation check to ObjectStorage read operation May 11, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

This was fixed by #105146. Let's update the branch.

@SmitaRKulkarni
SmitaRKulkarni requested a review from alesapin May 18, 2026 09:44
@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default and removed pr-not-for-changelog This PR should not be mentioned in the changelog labels May 18, 2026
@alesapin

Copy link
Copy Markdown
Member

test_keeper_reconfig_replace_leader_in_one_command is addressed by antonio

@clickhouse-gh

clickhouse-gh Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

🟢 AI verdict: improvement — 4 query(s) improved out of 38 analysed

This PR adds a test-only failpoint (storage_cluster_read_sleep) and a checkTimeLimit() call in the object-storage cluster read iterator so that S3/Iceberg cluster reads honor max_execution_time instead of hanging. None of this touches the query-execution path that ClickBench or TPC-H exercise (local MergeTree tables), so the flagged improvements are not attributable to the change. The smaller ClickBench deltas were downgraded as off-path baseline variance; four large deltas (ClickBench Q22/Q23, TPC-H Q7/Q20) are large and consistent enough to stand on their own, but they reflect a baseline build difference between the compared versions, not this PR.

clickbench

🟢 2 improved · ⚠️ 7 inconclusive

Flagged queries (9 of 43)
Query Verdict Baseline med (ms) PR med (ms) Change q-value Hint
🟢 22 improvement 334 236 -29.3% <0.0001 Large consistent delta held by trust rule; PR diff doesn't touch this path, likely a baseline build effect.
🟢 23 improvement 297 191 -35.7% <0.0001 -36% is large and consistent so stands, but the failpoint-only diff cannot explain it; baseline build shift.
⚠️ 4 not_sure 264 226 -14.4% <0.0001 PR only adds a failpoint + timeout check in object-storage cluster reads; ClickBench local-table path untouched.
⚠️ 15 not_sure 246 203 -17.5% <0.0001 Off-path: PR touches S3/Iceberg cluster read iterator only; this local-table query cannot be affected.
⚠️ 18 not_sure 1403 1276 -9.1% <0.0001 Off-path: change is in object-storage cluster reads, not the local query execution this runs on.
⚠️ 28 not_sure 7016 6572 -6.3% <0.0001 Off-path: PR adds a failpoint + timeout check to cluster object-storage reads, not this local query.
⚠️ 32 not_sure 1367 1268 -7.3% <0.0001 Off-path: object-storage cluster read change can't affect this local-table query; baseline variance.
⚠️ 33 not_sure 1488 1380 -7.3% <0.0001 Off-path: PR diff only touches S3/Iceberg cluster reads; this local query's path is unchanged.
⚠️ 34 not_sure 1486 1384 -6.9% <0.0001 Off-path: failpoint + timeout check in cluster reads; local query execution untouched.

q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 2 improved

Flagged queries (2 of 22)
Query Verdict Baseline med (ms) PR med (ms) Change q-value Hint
🟢 7 improvement 113 72 -36.3% <0.0001 -36% large and consistent so it stands, but query is noisy and the diff doesn't touch its path; baseline shift.
🟢 20 improvement 248 124 -50.0% <0.0001 -50% held by trust rule, but very noisy history and off-path diff; treat as baseline build, not this PR.

q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: 525737e4-6ce9-4fa0-9a5b-f4e8bd4732ee
  • MIRAI run: 0c2f2dbb-af17-4784-8724-445d215aae69
  • PR check IDs:
    • clickbench_187849_1781545225
    • clickbench_187861_1781545225
    • clickbench_187867_1781545225
    • tpch_adapted_1_official_187873_1781545225
    • tpch_adapted_1_official_187880_1781545225
    • tpch_adapted_1_official_187888_1781545225

@clickhouse-gh

clickhouse-gh Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.70% 84.70% +0.00%
Functions 92.40% 92.30% -0.10%
Branches 77.30% 77.30% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 23/23 (100.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 1 line(s) · Uncovered code

Full report · Diff report

auto task = callback();

if (auto query_status = getContext()->getProcessListElement())
query_status->checkTimeLimit();

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.

QueryStatus::checkTimeLimit has a non-throwing failure path: with timeout_overflow_mode = 'break', ExecutionSpeedLimits::checkTimeLimit returns false instead of throwing. This new cancellation boundary ignores that return value, so object-storage cluster reads can continue after max_execution_time once the delayed task callback returns, which violates the supported break timeout mode.

Please handle the false result here, for example by stopping the iterator before consuming the returned task:

if (auto query_status = getContext()->getProcessListElement())
    if (!query_status->checkTimeLimit())
        return nullptr;

and add a focused test with timeout_overflow_mode = 'break'.

@SmitaRKulkarni
SmitaRKulkarni added this pull request to the merge queue Jun 16, 2026
Merged via the queue into master with commit 70feef2 Jun 16, 2026
163 of 166 checks passed
@SmitaRKulkarni
SmitaRKulkarni deleted the icebergS3Cluster_large_data_fix branch June 16, 2026 09:50
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants