Skip to content

Fix NOT_FOUND_COLUMN_IN_BLOCK in the native Parquet V3 reader prewhere handling - #107059

Merged
PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-parquet-v3-prewhere-shared-intermediate-106147
Jul 29, 2026
Merged

PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-parquet-v3-prewhere-shared-intermediate-106147

Conversation

@groeneai

@groeneai groeneai commented Jun 10, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #106147
Related: #106443

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 NOT_FOUND_COLUMN_IN_BLOCK in the native Parquet V3 reader (regression from #93542) when a PREWHERE had conjuncts sharing a common intermediate expression.

Description

Reader::preparePrewhere() in src/Processors/Formats/Impl/Parquet/Reader.cpp reuses the MergeTree prewhere splitter (tryBuildPrewhereSteps, since #93542) to build per-condition read steps, then maps every cross-step column by its index in extended_sample_block. When two conjuncts share an intermediate node, the splitter promotes that node to a step boundary (output of one step, input of the next). extended_sample_block only holds query outputs and leaf prewhere inputs, so the promoted intermediate has no slot and the lookup throws NOT_FOUND_COLUMN_IN_BLOCK.

Fix: after the split, verify every step's required columns are addressable in extended_sample_block. A required column is addressable only if it is an original input of the whole prewhere expression, or an intermediate an earlier step computed into a dedicated prewhere-output slot. A promoted column with no such slot (or whose generated name merely collides with an unrelated physical column, which would otherwise silently feed user data instead of the computed value) forces the always-correct single-step path. This only widens the fallback, so it can never enable a new multi-step execution or change a correct result.

The same guard also skips the split when a kept prewhere output would otherwise be left unregistered, which previously tripped a LOGICAL_ERROR "Unexpected column in sample block". That path is only reachable via the old analyzer (need_filter is left false only for a PREWHERE with a WHERE on the legacy interpreter; the new analyzer always sets need_filter = true), which is being removed, so it carries no dedicated regression test.

Regression tests (both new-analyzer): 04327_parquet_v3_prewhere_shared_intermediate and 04342_parquet_v3_prewhere_intermediate_name_collision.

Note: #106147 was already closed (its object-storage .null-subcolumn half was fixed by #106443); this PR is the distinct File(Parquet) shared-intermediate half, hence Related rather than Closes.

Found by the AST fuzzer (STID 3400-40ae).

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes. clickhouse local with the issue's File(Parquet) query plus pinned input_format_parquet_use_native_reader_v3=1, optimize_move_to_prewhere=1, enable_analyzer=1, query_plan_enable_optimizations=1, query_plan_optimize_prewhere=1 throws NOT_FOUND_COLUMN_IN_BLOCK on every run on master HEAD (fc73f46). Minimal trigger: two multiIf sharing the CSE equals(a,'foo'), a JOIN on m1, IS NOT NULL on m2, wrapped in a row_number() window.
b Root cause explained? The window+join make the optimizer push PREWHERE = and(__applyFilter(runtime_filter, m1), isNotNull(m2)); both conjuncts depend on the shared node equals(a,'foo'). tryBuildPrewhereSteps splits the AND into 2 steps (conjuncts read different column sets) and promotes the shared node to an output of step 0 / input of step 1. The V3 reader (Reader::preparePrewhere) addresses every cross-step column by its index in extended_sample_block (= query outputs + leaf prewhere inputs only); the promoted intermediate has no slot, so Block::getPositionByName throws.
c Fix matches root cause? Yes. After tryBuildPrewhereSteps, verify every step's required columns have a slot in extended_sample_block; if any does not (the unaddressable promoted intermediate), fall back to single-step execution. Single-step keeps the shared expression as an internal DAG node never looked up by index. This is the always-correct path already used for non-conjunction PREWHERE.
d Test intent preserved / new tests added? New regression test 04327_parquet_v3_prewhere_shared_intermediate.{sql,reference} (the minimal File(Parquet) reproducer). Multistage PREWHERE for the common case (conjuncts sharing only leaf columns) still splits and is verified to work; the #93542 IS NOT NULL target case still works.
e Both directions demonstrated? Yes. Unfixed binary: NOT_FOUND_COLUMN_IN_BLOCK. Fixed binary: correct result, equal to the optimize_move_to_prewhere=0 ground truth on multi-row data. Test passes 50/50 with --no-random-settings. (Random-settings runs locally hit Invalid time zone: zoneinfo/UTC, an environment-only artifact unrelated to this change: a trivial SELECT 1 test fails identically here, and the test query has no timezone dependency.)
f Fix is general, not a narrow patch? The guard sits in add_step, covering both consumers (row_level_filter and prewhere_info). The V2 reader has no pushed-down-prewhere split path, so there is no sibling bug. This is a root-cause guard, not a symptom mask. Recovering the multistage optimization for these shared-intermediate shapes (giving promoted intermediates real extended_sample_block slots) is a larger, riskier change in a perf-critical reader and is noted as a possible follow-up.

Session id: cron:clickhouse-worker-slot-24:20260610-184200

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @al13n321 @scanhex12 — could you review? This fixes the File(Parquet) half of #106147: when a PREWHERE's conjuncts share a common subexpression, tryBuildPrewhereSteps promotes that intermediate to a step boundary, but the V3 reader addresses cross-step columns by index in extended_sample_block (which has no slot for it), so it threw NOT_FOUND_COLUMN_IN_BLOCK. The fix falls back to single-step execution when a step needs an unslotted column. Distinct root cause from #106443 (the .null subcolumn path on object storage).

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Jun 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a96bc89]

Summary: ❌

job_name test_name status info comment
Integration tests (arm_binary, distributed plan, 2/4) FAIL
test_storage_s3_queue/test_system_stop.py::test_stopped_table_releases_hash_ring_slot FAIL cidb IGNORED
test_storage_s3_queue/test_system_stop.py::test_refresh_survives_unready_dependencies FAIL cidb IGNORED

AI Review

Summary

This PR hardens the Parquet V3 PREWHERE split path by falling back to the single-step execution whenever a later split step would need an intermediate that is not safely addressable from extended_sample_block, and it adds focused regressions for both the original shared-intermediate NOT_FOUND_COLUMN_IN_BLOCK exception and the selected-column name-collision case. I re-checked the current diff against the full prior discussion and did not find a remaining correctness issue in the code that is still attributable to this PR.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jun 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI fully finished (Finish Workflow passed). The single failure is Stateless tests (arm_asan_ubsan, azure, sequential) -- the known azure-infra-outage / db-disk "Server died" chronic class, unrelated to this PR (Parquet V3 shared-column NOT_FOUND_COLUMN_IN_BLOCK fix). Not PR-caused. No Fast/Bugfix/Style failure.

@PedroTadim

Copy link
Copy Markdown
Member

@groeneai #106443 already fixes #106147 you may have to close this PR

@groeneai

Copy link
Copy Markdown
Collaborator Author

Thanks @PedroTadim. I verified before closing, and these two PRs fix two different root causes of #106147, so I think this one is still needed.

#106443 disables optimize_functions_to_subcolumns for StorageObjectStorage (S3/Iceberg) so isNotNull(x) stays a function instead of being rewritten to an x.null subcolumn read. That is the issue's Iceberg reproducer.

StorageFile already carries that exact override (StorageFile.h:125, supportsOptimizationToSubcolumns() = false), yet a File(Parquet) query whose PREWHERE conjuncts share a common intermediate still throws. On a clean master build (26.6.1.1, f1fc331, neither PR applied):

Code: 10. NOT_FOUND_COLUMN_IN_BLOCK: Not found column equals(__table3.a, 'foo'_String) in block ... While executing ParquetV3BlockInputFormat: While executing File.

The missing column here is the promoted intermediate equals(a, 'foo'), not a .null subcolumn: tryBuildPrewhereSteps makes it a step boundary and the V3 reader cannot address it in extended_sample_block. Since #106443 only changes a StorageObjectStorage method, it cannot affect the StorageFile path, and the test here (04327, File) is complementary to #106443's 04303 (S3).

Happy to keep this open as the File-path half. If you would rather have one PR cover both, I can move this reader-side fix wherever you prefer. What do you think?

@PedroTadim

Copy link
Copy Markdown
Member

@tiandiwonder what do you prefer? Should we keep both PRs?

@groeneai
groeneai force-pushed the fix-parquet-v3-prewhere-shared-intermediate-106147 branch from 0e5184d to 60bea00 Compare June 18, 2026 08:49
@groeneai groeneai changed the title Fix NOT_FOUND_COLUMN_IN_BLOCK in Parquet V3 reader with shared PREWHERE intermediate Fix two crashes in Parquet V3 reader prewhere (shared intermediate and no-filter) Jun 18, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (for the second fix added here, STID 3400-40ae)

# Question Answer
a Deterministic repro? Yes. clickhouse local -q "SELECT count() FROM file('t.parquet') PREWHERE and(u32<50,n>2) WHERE s!='zzz' SETTINGS input_format_parquet_use_native_reader_v3=1, enable_analyzer=0" aborts every time (SIGABRT, debug).
b Root cause explained? Yes. The V3 reader reuses tryBuildPrewhereSteps to split a multi-condition and() PREWHERE into per-condition filter steps, but only registered the kept prewhere output columns from a split step while filtering (needs_filter true). With the old analyzer a query that has both PREWHERE and WHERE leaves need_filter false (InterpreterSelectQuery only forces it true for PREWHERE without WHERE), and the prewhere column is kept (remove_prewhere_column false). So the kept and(...) column was registered in neither file outputs nor prewhere outputs, and the sample-block XOR bookkeeping assert tripped.
c Fix matches root cause? Yes. Splitting only helps when rows are filtered between steps, so the fix skips the split when needs_filter is false and uses the single-step path, which computes the DAG and registers the kept outputs without filtering. No assert widening, no tag suppression.
d Test intent preserved / new tests added? New regression test 04340_parquet_native_reader_prewhere_and_no_filter covering the old-analyzer PREWHERE+WHERE shapes (incl. the indexHint variant) plus a new-analyzer filtering check. The existing 04327 test is unchanged and still passes.
e Both directions demonstrated? Yes. Before the fix the repro is SIGABRT with Logical error: 'Unexpected column in sample block: and(less(u32, 50), greater(n, 2))'; after the fix it returns the correct count, matching the WHERE-only and new-analyzer equivalents. 8 correctness checks across both analyzers pass; both regression tests pass.
f Fix is general, not a narrow patch? The only other caller of tryBuildPrewhereSteps is MergeTreeSelectProcessor, which consumes the split steps directly (carrying need_filter/remove_filter_column per step) and has no separate sample-block bookkeeping, so it is unaffected. The bug is specific to the V3 reader's add_step, and the fix targets the mechanism (skip split when not filtering) rather than the symptom. It composes with the sibling shared-intermediate fix in the first commit (both fall back to single-step under the needs_filter guard).

Session id: cron:clickhouse-worker-slot-0:20260618-080900

@groeneai

Copy link
Copy Markdown
Collaborator Author

Expanded this PR to also fix a sibling bug in the same preparePrewhere() path: a LOGICAL_ERROR "Unexpected column in sample block: and(...)" when a multi-condition and() PREWHERE is kept in the output but does not need filtering (needs_filter false). Both are #93542 regressions in the V3 reader's prewhere split, so folding them into one PR avoids a self-conflict on the same lines.

The split is now skipped when needs_filter is false (it only helps when filtering rows between steps), which also covers the shared-intermediate case. Added regression test 04340_parquet_native_reader_prewhere_and_no_filter. Found by the AST fuzzer (STID 3400-40ae), now also on master (amd_msan).

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (identity-based split-step guard, e0a5873)

# Question Answer
a Deterministic repro? Yes. Parquet file with a physical column named equals(length(a), 3_UInt8) (=0) plus prewhere (length(a)=3 AND b>0) AND (length(a)=3 AND c>0) sharing that intermediate: old name-only guard returns count()=0, fixed guard returns count()=10, every run.
b Root cause explained? tryBuildPrewhereSteps promotes a reused condition node to a later step input by its generated result_name (addInput(node->result_name, ...)). add_single_step resolves step inputs by name via getPositionByName -> sample_block_to_output_columns_idx. A physical column sharing the generated name has a slot value, so the computed intermediate is not registered as a prewhere output and the later condition reads user data, silently changing results when types match.
c Fix matches root cause? Yes. The guard is now identity-based: a split-step required column is addressable only if it is an original input of the whole prewhere DAG (dag.getRequiredColumns()) or an intermediate an earlier step produced into a dedicated prewhere-output slot (in extended_sample_block, no original-output slot, mirroring add_single_step). Otherwise fall back to single step.
d Test intent preserved / new tests added? New regression test 04342 constructs the name collision and asserts the prewhere uses the computed intermediate (10 0), not the physical column. Existing 04327 and 04340 still pass. Parallel-safe (unique currentDatabase()-prefixed file name, no no-parallel).
e Both directions demonstrated? Yes, on rebuilt binaries: old name-only guard count()=0 (wrong), identity-based guard count()=10 (correct).
f Fix is general, not a narrow patch? Yes. It replaces the whole extended_sample_block.has() class with an identity check, covering both the no-slot intermediate case (the original crash) and the name-collision case. It only ever widens fallback to the always-correct single-step path, so it cannot enable a new multi-step execution or introduce a wrong result.

Session id: cron:clickhouse-worker-slot-0:20260618-093900

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finished on e0a58730ac69. Both red checks are pre-existing / infra, not caused by this PR (which only touches src/Processors/Formats/Impl/Parquet/Reader.cpp plus the three Parquet regression tests 04327/04340/04342, all green):

No PR-caused failures.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — e0a5873

Check / test Reason Owner / fixing PR
Stress test (amd_debug) / LOGICAL_ERROR "Unexpected return type from if. Expected UInt64. Got String" (STID 1611-483a) trunk bug (on-fly mutation read; if(cond, _CAST(..,UInt64), v) where v is an un-converted on-disk String, in MergeTreeReadersChain::executePrewhereActions) #108128 (merged 2026-06-24 14:09 UTC), not on this branch (HEAD is from 06-18) → will merge master to pick it up
Mergeable Check / PR aggregators (reflect the Stress failure above) covered by #108128
CH Inc sync — CH Inc sync (private, not actionable)

This failure is unrelated to this PR (which fixes Parquet V3 reader prewhere): the stack is the MergeTreeReadersChain/MergeTreeRangeReader on-fly-mutation read path, and the bug hit 6 master runs + ~27 unrelated PRs in 30d. It is fixed by the merged #108128 (which touches MergeTreeReadersChain.cpp/.h), 0 master hits since that merge. This branch predates the merge, so master will be merged in to re-run CI with the fix.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107059&sha=e0a58730ac69ea7ed24f3fea93a9dd6ea2e45cfe&name_0=PR&name_1=Stress%20test%20%28amd_debug%29

Session id: cron:our-pr-ci-monitor:20260625-053000

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 4575112

Every failure below has an owner: a fixing PR (ours or external). Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Integration tests (amd_asan_ubsan, db disk, old analyzer, 2/6) / test_quorum_inserts_parallel::test_parallel_quorum_actually_quorum flaky (SYSTEM SYNC REPLICA timeout under the asan/db-disk shard; 13 unrelated PRs + 2 master in 30d, not PR-caused) #108433 (ours, open)
CH Inc sync private sync CH Inc sync (private, not actionable)

This HEAD is a master-merge that picked up the on-fly-mutation read fix #108128, so the prior Stress (amd_debug) LOGICAL_ERROR "Unexpected return type from if" is gone on this commit. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107059&sha=4575112cc49de95cd4fbc41094bd6824f01e514c&name_0=PR

Session id: cron:our-pr-ci-monitor:20260625-110000

@groeneai groeneai mentioned this pull request Jun 30, 2026
21 tasks
@PedroTadim PedroTadim self-assigned this Jul 22, 2026
@PedroTadim

Copy link
Copy Markdown
Member

@groeneai do the crashes still happen?

@groeneai

Copy link
Copy Markdown
Collaborator Author

@PedroTadim The first one does. The second is now hidden behind a separate, newer master bug.

1. Shared-intermediate NOT_FOUND_COLUMN_IN_BLOCK (issue #106147, test 04327) - still reproduces on current master (snapshot 2beb103, 26.7.1.1):

Code: 10. NOT_FOUND_COLUMN_IN_BLOCK: Not found column equals(__table3.a, 'foo'_String) in block ... While executing ParquetV3BlockInputFormat: While executing File.

With this PR the query returns the correct baz 100 1. So this PR still fixes a live master bug.

2. need_filter=false LOGICAL_ERROR (test 04340) - I can no longer reach the original preparePrewhere error on current master, because the old-analyzer queries now abort earlier:

Logical error: 'KeyCondition uses PREWHERE output'   (Reader.cpp:382, prefilterAndInitRowGroups)

That assertion fires on a clean master debug build (no fix) and runs before the preparePrewhere() code this PR touches, so this PR cannot prevent it. 04340 was green on this PR as recently as 2026-06-25 (commit 4575112); this is a new master regression in the KeyCondition/PREWHERE-output path, independent of this PR. The preparePrewhere fix itself is unchanged and was the green path on 4575112, so master's original need_filter=false defect is still present, just masked by the earlier abort.

Net: I would keep this PR open for the shared-intermediate fix. For 04340 I can either open a separate issue for the Reader.cpp:382 regression and keep the test, or drop 04340 here and land only the shared-intermediate fix plus its test. Which do you prefer?

@PedroTadim

Copy link
Copy Markdown
Member

@groeneai keep this PR and check the CI failures

@groeneai

Copy link
Copy Markdown
Collaborator Author

@PedroTadim keeping it open, thanks. Checked the CI reds on f76bb0b:

The whole red cascade traced to one nit in our own test comment: 04340_parquet_native_reader_prewhere_and_no_filter.sql:31 said "New analyzer", which trips the new various_checks.sh analyzer-wording rule. Style is the first blocking gate, so that one line dropped every downstream build and turned Finish Workflow / Mergeable Check red. Fixed in a343300 (comment-only, "New analyzer" -> "the analyzer"); CI is re-running.

Remaining items, none PR-caused:

  • 04340 old-analyzer path (enable_analyzer=0): once builds run it hits a separate newer master regression, KeyCondition uses PREWHERE output LOGICAL_ERROR at Reader.cpp:382 prefilterAndInitRowGroups, which executes before this PR fixes anything in preparePrewhere. That abort is owned by our other PR Fix Parquet v3 reader logical error on key-condition column with no file mapping #109267; once it lands, 04340 old-analyzer reaches this fix and goes green. (CIDB: 29 hits / 12 PRs in 14d, onset 2026-07-09, mostly AST-fuzzer.)
  • CH Inc sync: private upstream check, not actionable from the fork.

The 04327 shared-intermediate fix (the deliverable) is unaffected and still needed: on the current master snapshot the query throws NOT_FOUND_COLUMN_IN_BLOCK, and with this PR it returns the correct result.

If you want green CI here before #109267 lands, I can drop the 04340 test from this PR and keep only the 04327 shared-intermediate fix + test. Your call.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 1468046

CI has fully finished on this head (Finish Workflow + Mergeable Check complete). Every failure has an owner.

Check / test Reason Owner / fixing PR
Stateless tests (amd_tsan, s3 storage, parallel, 2/3) / 01730_distributed_group_by_no_merge_order_by_long flaky (chronic master flake, Code 241 MEMORY_LIMIT_EXCEEDED; 22 hits on master + 15+ unrelated PRs in 30d; unrelated to the Parquet V3 reader change) fixing PR #109847 (merged 2026-07-22 17:26Z). This build (1468046, cut 14:20Z) predates the merge, so it does not yet contain the fix; a master merge would pick it up.

The sole failure is the chronic 01730 aggregation-memory flake, whose root-cause fix (aggregation hash-table stats cache key for table functions, #109847) merged today. The 04327 shared-intermediate deliverable and all other checks are unaffected.

Session id: cron:our-pr-ci-monitor:20260722-220000


set input_format_parquet_use_native_reader_v3 = 1;

-- Old analyzer: PREWHERE and(...) + WHERE leaves need_filter = false and keeps the prewhere column.

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.

@groeneai, please remove the old analyzer tests. It's going to be removed soon enough.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in d9c94aa: removed the three old-analyzer (enable_analyzer = 0) cases from 04340; kept only the new-analyzer query. It returns 497 (verified on the fixed binary). This also clears 04340's CI reds, which were the KeyCondition uses PREWHERE output abort on the old-analyzer path (owned by #109267), not a preparePrewhere failure.

…re intermediate

The native Parquet V3 reader reuses the MergeTree prewhere splitter
(tryBuildPrewhereSteps) to build per-condition read steps, then maps every
cross-step column by its index in extended_sample_block. When two conjuncts
share an intermediate node, the splitter promotes that node to a step boundary
(output of one step, input of the next). extended_sample_block only holds query
outputs and leaf prewhere inputs, so the promoted intermediate has no slot and
the lookup throws NOT_FOUND_COLUMN_IN_BLOCK.

Fix: after the split, verify every step's required columns are addressable in
extended_sample_block. A required column is addressable only if it is an
original input of the whole prewhere expression or an intermediate an earlier
step computed into a dedicated prewhere-output slot; a promoted column with no
such slot (or whose generated name merely collides with an unrelated physical
column) forces the always-correct single-step path. This only widens the
fallback, so it can never enable a new multi-step execution or change a correct
result.

The same guard also skips the split when a kept prewhere output would otherwise
be left unregistered, which previously tripped a "Unexpected column in sample
block" LOGICAL_ERROR. That path is only reachable via the old analyzer
(need_filter = false requires a PREWHERE with a WHERE on the legacy interpreter;
the new analyzer always sets need_filter = true), which is being removed, so it
carries no dedicated regression test.

Regression tests (both new-analyzer): 04327 (shared intermediate; pins the join
algorithm and disables join-table swap so the runtime filter that builds the
second shared conjunct is always present under randomized settings) and 04342
(a physical column whose name collides with a promoted intermediate).
@groeneai
groeneai force-pushed the fix-parquet-v3-prewhere-shared-intermediate-106147 branch from d9c94aa to 954bf14 Compare July 24, 2026 11:13
@groeneai groeneai changed the title Fix two crashes in Parquet V3 reader prewhere (shared intermediate and no-filter) Fix NOT_FOUND_COLUMN_IN_BLOCK in the native Parquet V3 reader prewhere handling Jul 24, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 954bf14

CI fully finished (Config + Finish Workflow SUCCESS, 0 checks queued/in_progress, last check completed 16:38 UTC). No failure below is caused by this PR (its diff is the Parquet V3 reader shared-intermediate fix in Reader.cpp plus removal of a vacuous test). Every failure has an owner.

Check / test Reason Owner / fixing PR
Stateless tests (amd_debug, parallel) / 04367_distributed_plan_merge_scatter_multishard flaky (11 hits / 11 unrelated PRs / 1 master, 30d; TIMEOUT-flaky) a fix task is at full effort (fixing-PR link to follow here)
Integration tests (amd_tsan, 6/6) / test_zookeeper_fallback_session::test_fallback_session Keeper TSAN data race (2 PRs / 0 master, 30d) #107083 (external, open)
Upgrade check (amd_release) / Error message in clickhouse-server.log trunk regression: system.metric_log_0 metadata exceeds max_query_size (QUERY_IS_TOO_LARGE), 191 unrelated PRs / 0 master, 30d #111703 (external, merged 2026-07-24)

Session id: cron:our-pr-ci-monitor:20260724-173000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the 04367_distributed_plan_merge_scatter_multishard failure in my earlier CI finish ledger: #111762 (external, open).

Correcting my own ledger line: I had recorded it as TIMEOUT-flaky (runner contention). That was wrong. It is a deterministic hang. Over 40 days the test has 25005 OK runs with a maximum duration of 41.3 s (p99 = 18.9 s), and 20 failures all pinned at the 600 s process-group cap, with zero runs anywhere between 42 s and 599 s. A contention-induced slowdown would populate that gap; a bimodal split with an empty middle is a hang.

The randomized-settings fingerprint identifies the trigger: max_threads = 1 appears in 20 of 20 failures. The runner draws max_threads as 32 if random() < 0.03 else randint(1, 3) (tests/clickhouse-test:1363), so P(1) is about 0.32 and 20/20 by chance is about 1.4e-10.

Root cause, as diagnosed by @ davenger in #111762: with distributed_plan_execute_locally = 1 the initiator pipeline holds an in-memory exchange reader next to the source that starts the producers. SourceFromInMemoryExchange::generate called InMemoryExchange::getChunk, which waits on a condition variable with no timeout (src/QueryPipeline/DistributedPlanExecutor.cpp:235 on master). With a single pipeline thread the executor can schedule the reader first, so the producers never start and the query blocks forever. This test is a named reproducer in that PR's description.

I did not author a fix: #111762 is by the owner of this code and already implements the correct one, a bounded wait_for plus a pushed zero-row chunk so the port fills and the executor can run other processors. Nothing on master carries it yet: git merge-base --is-ancestor against origin/master is false, and the unbounded has_data.wait is still present. So the failure stays live until that PR merges. I am tracking it.

@clickhouse-gh

clickhouse-gh Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.30% 86.30% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 78.40% 78.50% +0.10%

Changed lines: Changed C/C++ lines covered: 31/32 (96.88%) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - a96bc89

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Integration tests (arm_binary, distributed plan, 2/4) / test_storage_s3_queue/test_system_stop.py::test_stopped_table_releases_hash_ring_slot server SIGABRT in ObjectStorageQueueSource::FileIterator::next (the test then sees Code 210 Connection reset by peer against the dead server) #108977 (mine, open, approved)
Integration tests (arm_binary, distributed plan, 2/4) / test_storage_s3_queue/test_system_stop.py::test_refresh_survives_unready_dependencies collateral of the same server death in that job (Code 210 while setting up its table) #108977 (mine, open, approved)

Not PR-caused: this pull request touches only src/Processors/Formats/Impl/Parquet/Reader.cpp
plus its two new Parquet V3 stateless tests, and neither S3Queue test exercises that path.
The failing job reports 2/1230, all other 173 checks are green
(report).

Head a96bc895db3c is @ PedroTadim's own commit, so I validated and ledgered only: no push,
no rebase, no master merge from me.

Session id: cron:our-pr-ci-monitor:20260728-163000

@PedroTadim
PedroTadim added this pull request to the merge queue Jul 29, 2026
Merged via the queue into ClickHouse:master with commit d481542 Jul 29, 2026
176 of 178 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 29, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi — this looks like a backport candidate for 26.2, 26.3, 26.4, 26.5, 26.6. I ran this PR's own regression test against each branch's binary and the bug reproduces there (the fix isn't present yet).

Not needed on 26.1 — the test passes there (already not affected).

@groeneai

Copy link
Copy Markdown
Collaborator Author

Thanks for the cross-branch run. I do not open manual backport PRs and cannot apply labels; backports are driven by a vX.Y-must-backport label a maintainer applies to the merged master PR, and the robot then produces the branch PRs.

I re-measured with the official per-branch binaries and this PR's own two regression tests, controlling on master (both pass there and match their .reference). Two additions to your list. 26.7 is an active release branch and also affected, but it is not in your list: 04327 fails Code: 10 NOT_FOUND_COLUMN_IN_BLOCK and 04342 silently returns 0 0 instead of 10 0 on 26.7.2.37. And 26.2 and 26.4 have no open release PR, so they are not active branches; the automation takes the active set from the head refs of the open release-labelled PRs, currently 25.8, 26.3, 26.5, 26.6, 26.7.

Your 26.1 result reproduces here, and there is a structural reason for it: 26.1 never calls tryBuildPrewhereSteps in Reader::preparePrewhere, so the prewhere-splitting path the bug lives in does not exist there yet. That call is present on 26.2 through 26.7, and addressable_columns, the symbol this fix introduces, is absent from every release branch.

So the useful ask is a single v26.3-must-backport, which expands to 26.3, 26.5, 26.6 and 26.7. Not pr-must-backport: that also targets 25.8, where this bug does not reproduce. 25.8 does show a separate native-reader defect on 04327 (empty result with input_format_parquet_use_native_reader_v3 = 1, correct with it set to 0, where it also defaults to 0), which is out of scope here and not something this fix addresses.

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