Skip to content

Fix flaky test 05409_quota_on_profile_events_remote_insert_mv_dedup - #132139

Merged
fm4v merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05409-quota-remote-insert-mv-dedup
Nov 18, 2026
Merged

fm4v merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05409-quota-remote-insert-mv-dedup

Conversation

@groeneai

@groeneai groeneai commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

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

Related: #131791
Related: #117004

The test asserts the exact SelectedRows quota charge (108) of a distributed INSERT whose remote materialized view reads dim_05409 (100 rows) through remote. CI got 116 in Stateless tests (arm_binary, AsyncInsert, s3 storage, parallel) and 110 in Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel).

The randomized merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability is forwarded with the INSERT to the remote servers. When it fires on a read with several streams, the granule on each layer border is read by both layers (the result is right), so SelectedRows grows by one granule: +8 at index_granularity 8, +2 at 1. In both jobs' query_log, exactly the dim_05409 reads carrying the splitter's filter over-count. A part this small gets several streams only on object storage.

The change clamps the injection to 0 for this test, the same header as #129987 (05508). Every other setting stays randomized.

Validation (master debug binary): injection forced to 1 gives 116 4/4, 0 gives 108 4/4. With index_granularity 8 pinned and the rest randomized, the old test fails 18/30 (local disk, forced concurrency) and 9/30 (s3), the new one 0/30 on both. The injection is nonzero in 0/2820 of the test's queries in system.query_log with the clamp, 920/940 with a misspelled one. Default randomization: 50/50 on local disk and on s3. The sibling 05257 keeps its reference under forced injection, so it is unchanged.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.2794-master (included in 26.11 and later)

The second section asserts the exact `SelectedRows` quota charge (108) of a
distributed `INSERT` whose materialized view on the remote server reads
`dim_05409` (100 rows) through `remote`. CI got 116 and 110 on two PRs, both
in `arm_binary ... s3 storage, parallel` jobs.

The randomized `merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability`
is forwarded with the `INSERT` to the remote servers. When the coin fires on a
read with more than one stream, `ReadFromMergeTree::spreadMarkRangesAmongStreams`
splits the ranges into layers with `splitPartsWithRangesByPrimaryKey`, and the
granule on a layer border is read by both pipes (the PK-boundary filter drops
the duplicates, so the result is right). `SelectedRows` counts that granule
twice: +8 at `index_granularity` 8 (116), +2 at `index_granularity` 1 (110).
A 100-row part gets several streams on object storage, where the
concurrent-read thresholds are 0, which is why only the s3 jobs failed.

Clamp the injection to 0 for this test with the runner's per-setting limit,
the same header as 05508 (ClickHouse#129987). Every other setting stays randomized.

Related: ClickHouse#131791

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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; 0 findings) plus an independent cold review of the diff (0 findings).

Checked: the Random settings limits: header is parsed for .sh tests (comment sign #) and clamps the randomized value before the client command line is built; the injection setting defaults to 0 and no test config profile sets it, so both remote hops read without the splitter; the exactly-once assertion (108) and the rest of the randomization are unchanged; the header is byte-identical to the one 05508 already carries.

# Sev Finding Verdict Evidence / action
- - none - -

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-10:20261116-205800

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Running the test directly with --merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability 1 --index_granularity 8 --max_threads 3 --merge_tree_min_rows_for_concurrent_read 1 --merge_tree_min_bytes_for_concurrent_read 1 --use_query_condition_cache 0 prints 116 1 in 4/4 runs (the CI value); the same with probability 0 prints 108 1 in 4/4 runs.
b Root cause explained? The randomized injection is forwarded with the INSERT to the remote servers. When it fires on the view's dim_05409 read with several streams, the granule on each layer border is read by both layers, so SelectedRows grows by one granule (+8 at index_granularity 8, +2 at 1) and the quota charge becomes 116 / 110 instead of 108. Locally the over-counting read has read_rows 108 and the splitter's filter functions (greater, not); the clean one has 100 and none, matching both CI jobs' query_log.
c Fix matches root cause? Yes. The per-setting header clamp removes only that test-only injection from this test. The double read is real work, so the accounting is correct; no bound is widened and no blanket tag is added.
d Test intent preserved / new tests added? Yes. Assertions and reference are unchanged; every other setting stays randomized (the injection is 0 in 2820 of 2820 queries of 30 randomized runs, all other draws intact). Test-only change, no source change.
e Both directions demonstrated? Yes. Runner with index_granularity 8 pinned, rest randomized: old test 18/30 FAIL on local disk with forced concurrency and 9/30 on s3 storage, all 116 1; new test 0/30 and 0/30. Misspelled clamp: injection nonzero in 920/940 queries, so the clamp is what changes the outcome. 50/50 on local disk and 50/50 on s3.
f Fix is general across code paths? N/A (test-only fix). Sibling 05257 checked under the same forced injection at index_granularity 8 and 1: output matches its reference and its read is never split, so it is unchanged; 05508 already carries the same clamp.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only fix); validated at both granularities seen in CI (8 and 1) and on local and s3 storage.
h Backward compatible? (maintainer-approved exception only) N/A: no setting, format or protocol change.
i Invariants and contracts preserved? N/A for engine invariants (no source change). The test's invariant, each row read charged once, holds: 100 (dim read) + 4 (remote insert) + 4 (initiator) = 108.

Session id: cron:clickhouse-impl-slot-5:20261116-203821

@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d96e5d0]

Summary: ✅


AI Review

Summary

This PR disables randomized PartsSplitter fault injection for the remote-insert materialized-view quota test, preventing boundary-granule rereads from changing its exact SelectedRows expectation. The change preserves the quota assertions and other randomized settings. No actionable findings.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 16, 2026

@clickhouse-gh clickhouse-gh Bot left a comment

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.

AI review approves this commit, see the AI Review comment.

@fm4v
fm4v added this pull request to the merge queue Nov 18, 2026
Merged via the queue into ClickHouse:master with commit 139305e Nov 18, 2026
384 of 385 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 Nov 18, 2026
@clickhouse-gh clickhouse-gh Bot added comp-rbac Authorization: roles, grants, quotas, row-level security, access checks. 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-rbac Authorization: roles, grants, quotas, row-level security, access checks. 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