Skip to content

Report the real error when an in-place IN-set build destroys its source - #114983

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-not-ready-set-after-failed-inplace-build
Aug 17, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-not-ready-set-after-failed-inplace-build

Conversation

@alexey-milovidov

Copy link
Copy Markdown
Member

FutureSetFromSubquery::buildOrderedSetInplace speculatively builds the set of an IN subquery during index analysis. A subquery whose source plan cannot be cloned - a read from a remote cluster, for example - takes the destructive path there, which consumes the source plan. When that build then throws, the set can never be built again: build returns a null plan, every caller takes that for "nothing left to build", and the query keeps running with an unready set until FunctionIn reports the logical error Not-ready Set is passed as the second argument for function 'in'.

That is exactly what happens whenever a caller deliberately ignores an in-place build failure. Statistics-based part pruning is such a caller: it logs the failure and keeps reading the part whose condition it could not evaluate. So

SELECT count() FROM t
WHERE a IN (SELECT a FROM clusterAllReplicas('cluster_with_an_unavailable_replica', currentDatabase(), t))

reported Not-ready Set instead of the connection error, which aborts the server in a build with abort_on_logical_error.

The failure of a destructive in-place build is remembered now and rethrown from build instead of returning a null plan, so the query fails with the real reason - the same error it fails with when no in-place build is attempted at all.

This is the cause of the recurring master Stress test failure Logical error: Not-ready Set is passed as the second argument for function 'A (STID: 0250-3e49), seen on arm_release and arm_msan a few times a day since 2026-07-23:

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=2926be24e6102daae60b8f44c88969495a76ec3c&name_0=MasterCI&name_1=Stress%20test%20%28arm_release%29

Related: #107924
Related: #107619

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):

Fix the logical error Not-ready Set is passed as the second argument for function 'in' for a query with an IN subquery reading from a remote cluster: the query now fails with the actual error from the subquery, such as a connection failure.

…urce

`FutureSetFromSubquery::buildOrderedSetInplace` speculatively builds the set
of an `IN` subquery during index analysis. A subquery whose source plan
cannot be cloned - a read from a remote cluster, for example - takes the
destructive path, which consumes `source`. When the build then throws, the
set can never be built again: `build` returns a null plan, every caller
takes that for "nothing left to build", and the query keeps running with an
unready set until `FunctionIn` reports the logical error `Not-ready Set is
passed as the second argument for function 'in'`.

That is exactly what happens whenever a caller deliberately ignores an
in-place build failure. Statistics-based part pruning is such a caller: it
logs the failure and keeps reading the part whose condition it could not
evaluate. So

    SELECT count() FROM t
    WHERE a IN (SELECT a FROM clusterAllReplicas('cluster_with_an_unavailable_replica', currentDatabase(), t))

reported `Not-ready Set` instead of the connection error, aborting the
server in a build with `abort_on_logical_error`.

Remember why the destructive in-place build failed and rethrow it from
`build` instead of returning a null plan. The query now fails with the real
reason - the same error it fails with when no in-place build is attempted at
all.

This is the cause of the master `Stress test (arm_release)` failure
`Logical error: Not-ready Set is passed as the second argument for
function 'A (STID: 0250-3e49)`:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=2926be24e6102daae60b8f44c88969495a76ec3c&name_0=MasterCI&name_1=Stress%20test%20%28arm_release%29
@clickhouse-gh

clickhouse-gh Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [38e13b3]

Summary: ✅


AI Review

Summary

This PR preserves the original subquery exception when a destructive speculative IN-set build consumes its source, instead of letting the query continue until FunctionIn reports Not-ready Set. The remembered-failure path in FutureSetFromSubquery::build is consistent with that contract, and the new regression test exercises the statistics-pruning path that previously swallowed the first exception. I did not find any blocking issues in the current diff.

Final Verdict

✅ No blocking issues found.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.70% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 79.10% 79.10% +0.00%

Changed lines: Changed C/C++ lines covered: 45/48 (93.75%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 16, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 38e13b3ef with master 2a539919d (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of aec8b1d56; 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 694.46 MiB 691.45 MiB -3.01 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

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

Job report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks like a good change.

@alexey-milovidov alexey-milovidov self-assigned this Aug 17, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 17, 2026
Merged via the queue into master with commit d092f96 Aug 17, 2026
182 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-not-ready-set-after-failed-inplace-build branch August 17, 2026 22:10
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 17, 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.

2 participants