Skip to content

Fix flaky test 04007_pipeline_stuck_ping_pong_deadlock - #107565

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix/04007-pipeline-stuck-no-random-mt-settings
Jun 20, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix/04007-pipeline-stuck-no-random-mt-settings

Conversation

@groeneai

@groeneai groeneai commented Jun 15, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #57728

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

04007_pipeline_stuck_ping_pong_deadlock is a pipeline-deadlock regression test (issue #57728): it checks that a full_sorting_merge join using the PingPongProcessor / FilterBySetOnTheFly optimization no longer hangs. The deadlock detection is driven entirely by the pinned query-level SETTINGS (join_algorithm = 'full_sorting_merge', query_plan_join_swap_table = 0, max_threads = 2) and is independent of the table's on-disk layout.

CI randomizes MergeTree settings per run, and two unrelated randomized combinations break this test without exercising any new pipeline behavior:

  1. index_granularity = 1 with min_bytes_for_wide_part = 0 produces ~1M marks for the 1M-row tables, making each INSERT roughly 20x slower. On the slow amd_msan / WasmEdge runner this pushes the total runtime past the 180s timeout. The query still returns the correct result, so it is pure slowness, not a deadlock.
  2. part_minmax_index_columns = 'with_block_number_offset' without enable_block_number_column / enable_block_offset_column is rejected at CREATE TABLE with BAD_ARGUMENTS (seen on amd_tsan and arm_binary).

A single-setting pin cannot cover both classes, and the test does not depend on MergeTree storage randomization for any of its coverage. The fix adds the no-random-merge-tree-settings tag, which disables only MergeTree-settings randomization while leaving session-level setting randomization (where the pipeline / join behavior lives) intact. The same tag is used by sibling tests (00564, 00926, 02981) for the same reason.

Validated locally: with MergeTree randomization the test fails (BAD_ARGUMENTS / timeout); with the tag it passes 50/50 under full randomization.

Version info

  • Merged into: 26.6.1.1

This is a pipeline-deadlock regression test (issue ClickHouse#57728): it checks that a
full_sorting_merge join with the PingPongProcessor / FilterBySetOnTheFly
optimization no longer hangs. The deadlock detection is driven entirely by the
pinned query-level SETTINGS (join_algorithm = 'full_sorting_merge',
query_plan_join_swap_table = 0, max_threads = 2) and is independent of the
table's on-disk layout.

CI randomizes MergeTree settings per run, and two unrelated randomized
combinations break this test without exercising any new pipeline behavior:

  1. index_granularity = 1 with min_bytes_for_wide_part = 0 produces ~1M marks
     for the 1M-row tables, making each INSERT ~20x slower. On the slow
     amd_msan / WasmEdge runner this pushes the total runtime past the 180s
     timeout (seen on PR ClickHouse#101143). The query still returns the correct result;
     it is pure slowness, not a deadlock.
  2. part_minmax_index_columns = 'with_block_number_offset' without
     enable_block_number_column / enable_block_offset_column is rejected at
     CREATE TABLE with BAD_ARGUMENTS (seen on PR ClickHouse#106734, amd_tsan and
     arm_binary).

Pinning a single setting cannot cover both classes, and the test does not
depend on MergeTree storage randomization for any of its coverage. Add the
no-random-merge-tree-settings tag, which disables only MergeTree-settings
randomization while leaving session-level setting randomization (where the
pipeline / join behavior lives) intact. The same tag is used by sibling tests
(00564, 00926, 02981) for the same reason.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes. Untagged + MergeTree randomization: clickhouse-test --merge-tree-settings-file <part_minmax_index_columns=with_block_number_offset> → [ FAIL ] BAD_ARGUMENTS every run (the #106734 class). The #101143 class is the CI's own randomized-settings diagnosis: reproduces 1/1 with the failing settings, passes 17/17 without (CIDB report). Locally, index_granularity = 1, min_bytes_for_wide_part = 0 makes each 1M-row INSERT ~1.13s vs ~0.05s default — a ~20x slowdown that times out the slow amd_msan/WasmEdge runner.
b Root cause explained? Yes. The test is a pipeline-deadlock regression (issue #57728); its detection depends only on the pinned query SETTINGS (join_algorithm = 'full_sorting_merge', query_plan_join_swap_table = 0, max_threads = 2), not on storage layout. CI's per-run MergeTree randomization injects two unrelated breakages: (1) index_granularity = 1 → ~1M marks for 1M rows → INSERT ~20x slower → 180s timeout on slow builds (the query still returns the correct 500000, so it is slowness not a deadlock); (2) part_minmax_index_columns = 'with_block_number_offset' without enable_block_number_column/enable_block_offset_column → BAD_ARGUMENTS at CREATE TABLE.
c Fix matches root cause? Yes. Both failure classes are MergeTree-settings-randomization artifacts and the test draws no coverage from storage-layout randomization. no-random-merge-tree-settings disables exactly that (verified at source tests/clickhouse-test:2515-2523: the tag sets base_mt_settings = {}) while leaving session-level --random-settings — where the pipeline/join behavior lives — fully active. A single-setting pin cannot cover both unrelated classes.
d Test intent preserved / new tests added? Yes. The query, the pinned join SETTINGS, and the .reference (500000) are unchanged, so the test still exercises and asserts the same PingPongProcessor / full_sorting_merge deadlock path. Session-level randomization remains on. No source code changed, so no new regression test is needed.
e Both directions demonstrated? Yes. Without the tag (MergeTree randomization on): [ FAIL ]. With the tag: 50/50 OK under full randomization (clickhouse-test --test-runs 50), all ~0.35s, no hung queries.
f Fix is general, not a narrow patch? N/A (flaky-test settings fix, not a code bug). The tag is the established pattern for this exact situation; sibling tests 00564, 00926, 02981 use it for the same reason.

Session id: cron:clickhouse-worker-slot-3:20260615-194100

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

clickhouse-gh Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f5fd7bb]

Summary: ❌

job_name test_name status info comment
Stateless tests (arm_asan_ubsan, azure, sequential) FAIL
03232_workloads_and_resources ERROR cidb
Server died FAIL cidb, issue
Segmentation fault (STID: 0883-50e0) FAIL cidb
Scraping system tables FAIL cidb

AI Review

Summary

This PR adds the no-random-merge-tree-settings tag to 04007_pipeline_stuck_ping_pong_deadlock, keeping the pipeline-deadlock regression focused on the pinned query-level SETTINGS while preventing unrelated randomized MergeTree table settings from causing BAD_ARGUMENTS exceptions or timeout-level insert slowdowns. The change is scoped to one stateless test, matches the CI Fix or Improvement category, and the latest direct Praktika report for commit f5fd7bba90477521f2439ba1d0503f7920170ef7 shows no failed tests.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 15, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, we have to fix

Stress test (amd_tsan) FAIL
Received signal 6 (internal) (STID: 7594-4269)

@groeneai

Copy link
Copy Markdown
Collaborator Author

@alexey-milovidov This Stress (amd_tsan) signal 6 (STID 7594-4269) is a re-introduced trunk crash, not caused by this PR. #107565 only retags 04007_pipeline_stuck_ping_pong_deadlock and does not touch DistributedPlanExecutor; the stress run merely surfaced it.

The crash is std::terminate escaping ~DistributedQueryPlanExecutorRemote via ~TaskTracker calling ThreadPool::wait(), which rethrows the pool's stored first exception. The status-check lambda's tail (enqueueGetStatus() -> scheduleOrThrow) is outside the lambda's try/catch, so under shutdown (CANNOT_SCHEDULE_TASK) or serverfuzz fault injection (MEMORY_LIMIT_EXCEEDED) the throw escapes the lambda, is stored in the pool, and is rethrown from the noexcept destructor.

It comes from the re-landed Multistage distributed queries feature (#106020). The same crash was previously taken to zero on master by revert #107122 and is back since the re-land. The same signature appears on 18+ unrelated PR branches and master in the last 30 days. Report for this sighting: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107565&sha=8696805ace5dc74831f1ee4ac4645fbe5d43d71d&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29

Fix in progress in a separate PR: wrap the lambda tail in the class's existing try/catch so re-enqueue failures land in TaskTracker's own exception channel, and make ~TaskTracker() exception-safe (try { thread_pool.wait(); } catch (...) { tryLogCurrentException(...); }, keeping wait() so threads join while members are still alive), with a deterministic failpoint regression test. The sibling re-land bug (null-AST deref when logging a local task) is already up as #107570; I will link the TaskTracker fix PR here once pushed.

@groeneai

Copy link
Copy Markdown
Collaborator Author

@alexey-milovidov The TaskTracker fix is up: #107575. It makes the distributed-plan worker status-check re-enqueue and ~TaskTracker exception-safe, so the ~DistributedQueryPlanExecutorRemote signal 6 (STID 7594-4269) now fails the query cleanly instead of aborting the server, with a deterministic failpoint regression test. Once it merges this Stress (amd_tsan) crash should clear, and #107565's 04007 retag can be re-evaluated on its own.

@davenger

Copy link
Copy Markdown
Member

@groeneai The TaskTracker fix #107575 has been merged into master. You can update this branch so that CI can re-run the checks

@alexey-milovidov alexey-milovidov self-assigned this Jun 16, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

@davenger The branch already picked up the merged fix #107575 (alexey-milovidov merged master in as f5fd7bb); CI is re-running on that head now. The earlier Stress (amd_tsan) signal 6 (STID 7594-4269) was that crash, so it should clear this run. I will confirm once the checks finish.

@clickhouse-gh

clickhouse-gh Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.20% -0.10%
Functions 92.30% 92.30% +0.00%
Branches 77.50% 77.50% +0.00%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 382 line(s), 25 function(s) across 124 file(s) · Details

Top files
  • src/Storages/StorageReplicatedMergeTree.cpp: 42 line(s)
  • src/Dictionaries/SSDCacheDictionaryStorage.h: 16 line(s), 10 function(s)
  • src/Storages/Statistics/ConditionSelectivityEstimator.cpp: 12 line(s), 2 function(s)
  • src/AggregateFunctions/AggregateFunctionQuantileExact.cpp: 8 line(s)
  • src/Common/ZooKeeper/ZooKeeperImpl.cpp: 8 line(s)

Full report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finished on f5fd7bba9047 (Finish Workflow green). The only red is one azure shard:

  • Stateless tests (arm_asan_ubsan, azure, sequential) - Segmentation fault (STID: 0883-50e0) plus its server-death victims (03232_workloads_and_resources ERROR, Server died). This is an alloc-time SEGV inside the ASan allocator while servicing a ReadBufferFromFileDescriptor own-memory buffer - an innocent victim of the known arm_asan_ubsan azure-sequential DoRecycle/Quarantine heap-corruption family (free/alloc-time SEGVs over metadata corrupted earlier in another thread). Not caused by this PR (a no-random-merge-tree-settings tag change to 04007_pipeline_stuck_ping_pong_deadlock, not in any crash path). STID 0883-50e0 has 7 hits/30d scattered across unrelated PRs, all on *asan_ubsan, azure. Tracked in our family umbrella; the prior blocking Stress (amd_tsan) signal-6 crash is gone after the TaskTracker fix Fix server abort when a distributed-plan worker status check fails to re-enqueue #107575 landed.

CH Inc sync is the internal-fork mirror check (not a ClickHouse CI job). No PR-caused failures. The 04007 retag itself is clean.

alexey-milovidov added a commit that referenced this pull request Jun 19, 2026
…anch

This branch was accidentally created on top of
`fix/04007-pipeline-stuck-no-random-mt-settings` (PR #107565) instead of
`master`, so it carried that PR's change to
`04007_pipeline_stuck_ping_pong_deadlock.sql` (a `no-random-merge-tree-settings`
tag addition). That change is unrelated to this XDBC fix.

It also made "Bugfix validation (functional tests)" fail: as this PR is labelled
"Bug Fix", that job runs the changed functional tests against the unfixed binary
and expects them to reproduce the bug, but the tag-only change passes there, so
the job reported "Failed to reproduce". This XDBC fix is exercised by the
integration test `test_jdbc_bridge_hang` instead, which the integration bugfix
validation already confirmed.

Restore the file to its `master` content; the tag fix stays with PR #107565.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov
alexey-milovidov merged commit f5fd7bb into ClickHouse:master Jun 20, 2026
163 of 165 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 20, 2026
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-ci 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.

5 participants