Skip to content

Keep the quorum INSERT of 04405_mergetree_compact_cancel_after_finish single-stream - #122992

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04405-quorum-insert-single-stream
Sep 30, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04405-quorum-insert-single-stream

Conversation

@groeneai

@groeneai groeneai commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #122913

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

04405_mergetree_compact_cancel_after_finish expects its quorum INSERT to fail with UNKNOWN_STATUS_OF_INSERT (319) from the replicated_merge_tree_insert_quorum_fail_0 failpoint, and sometimes gets UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE (286) instead: 5 failures on 5 unrelated PRs in 60 days, none on master, e.g. Stateless tests (amd_asan_ubsan, flaky check) on #122913 and Fast test on #120080.

Root cause. Since #109006 made max_insert_threads default to the number of cores, this INSERT ... SELECT writes through several ReplicatedMergeTreeSinks; the test was written when it had one. The sink that receives the rows commits all_0_0_0, which creates the non-parallel quorum node, and raises the expected 319 at the failpoint. A sink without rows whose onStart runs later finds that node in checkQuorumPrecondition and raises 286, which reaches the client first. The flaky check's server log shows both: 319 raised by the sink that wrote the part, 286 returned to the client.

Fix. Pin max_insert_threads = 1 on that INSERT, as 04912_pr_classic_pinned_block_numbers and 05211_prewhere_column_sizes_pinned_block_numbers do. A single sink runs its onStart before its own commit, so the 286 cannot happen, and the exact 319 assertion stays. Keeping a non-parallel quorum INSERT ... SELECT single-stream in the engine is part of #113045.

Validation (master build):

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.1046-master (included in 26.10 and later)

… single-stream

Since ClickHouse#109006 made `max_insert_threads` default to the number of cores, the
test's `INSERT ... SELECT` writes through several `ReplicatedMergeTreeSink`s;
the test was written when it had one. The sink that receives the rows commits
`all_0_0_0`, which creates the non-parallel quorum node, and raises the
expected `UNKNOWN_STATUS_OF_INSERT` at the
`replicated_merge_tree_insert_quorum_fail_0` failpoint. A sink without rows
whose `onStart` runs later then finds that node in `checkQuorumPrecondition`
and raises `UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE`, which reaches the client
first.

Pin `max_insert_threads = 1` on that INSERT, as 04912 and 05211 already do.
A single sink runs `onStart` before its own commit, so the second error cannot
happen. The exact error assertion and the cancel-after-finish path the test
covers are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Sep 30, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding).

# Sev Finding Verdict Evidence / action
1 ⚠️ The test does not deterministically prove the quorum INSERT has one sink; asks for an EXPLAIN PIPELINE sink-count assertion under a higher session-level max_insert_threads. DISAGREE An EXPLAIN is a separate statement with its own copy of the SETTINGS, so it cannot see whether the executed INSERT keeps the pin, and system.processors_profile_log is not written for a failed query. The engine side (max_insert_threads = 1 gives one sink) is already pinned by 04492_max_insert_threads_for_direct_insert and 03531_insert_removing_sparse_transform. The pin adds no detection power: with the null guards in MergeTreeDataPartWriterCompact::cancel reverted, the unpinned test crashes the server in the same frame as the pinned one. Same bare pin as 04912 and 05211. No change.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20260930-000800

@clickhouse-gh

clickhouse-gh Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4e1b7e0]

Summary: ✅


AI Review

Summary

This PR stabilizes 04405_mergetree_compact_cancel_after_finish by pinning max_insert_threads = 1 on the quorum INSERT ... SELECT, which removes the sibling-sink race that can return UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE before the intended UNKNOWN_STATUS_OF_INSERT. I did not find a correctness issue in the change itself: the single-sink path still finalizes the compact part, commits it locally, and then hits the same quorum-wait failpoint, so the original MergeTreeDataPartWriterCompact::cancel regression remains covered.

Missing context / blind spots
  • ⚠️ CI on commit 4e1b7e09e47beb10550306c69660385c93ca1892 was still pending when I reviewed, and I did not rerun the stateless test locally. A green Fast test or Stateless tests result would close that gap.
Final Verdict

✅ No inline findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 30, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Sep 30, 2026
@Algunenano Algunenano self-assigned this Sep 30, 2026
@Algunenano
Algunenano added this pull request to the merge queue Sep 30, 2026
Merged via the queue into ClickHouse:master with commit f84d2c0 Sep 30, 2026
149 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 Sep 30, 2026
@clickhouse-gh clickhouse-gh Bot added comp-replication ReplicatedMergeTree* + replication log/state transitions, eventual consistency mechanics. and removed comp-testing Test content only (no production code). labels Nov 22, 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 comp-replication ReplicatedMergeTree* + replication log/state transitions, eventual consistency mechanics. groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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.

3 participants