Skip to content

Fix flaky test 05367_text_index_embedded_positions under parallel replicas - #129610

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05367-text-index-embedded-positions
Nov 6, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05367-text-index-embedded-positions

Conversation

@groeneai

@groeneai groeneai commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #125630

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

Not required.

Description

Failure: Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) on master 7833893d3bb6: the last block printed 05367_embedded 0 0 instead of 1 0. It failed 4 times in about 650 runs of that check since the test was added in #125630, and nowhere else.

The last query read TextIndexPositionsBlocksRead and TextIndexPositionsBytesRead only from the initiator's query_log row (current_database = currentDatabase()). These counters are incremented on the replica that reads the granule. In the ParallelReplicas configuration the merged part has one mark, and sometimes a remote replica reads it; that replica's row has current_database = 'default', so the initiator row shows 0. The failing job's own query_log shows the initiator row with ParallelReplicasReadMarks = 0 and a secondary row of the same initial_query_id with ParallelReplicasReadMarks = 1 and TextIndexPositionsBlocksRead = 2; their sum is the reference value.

The query now sums both counters over every QueryFinish row that shares the initiator's initial_query_id, as 05232_text_index_lazy_intersection_block_span_rule does. The tested queries and the reference are unchanged, so the test keeps its parallel replicas coverage.

Validation (master debug build, local copy of the ParallelReplicas configuration with three replicas):

  • parallel_replicas_local_plan = 0: old 20/20 fail, new 20/20 pass; keeping only initiator rows in the new query fails 20/20.
  • failpoint slowdown_parallel_replicas_local_plan_read: the old test fails in exactly the 52 of 80 randomized runs where a remote replica read the mark, the new one passes 80/80 with 43 such runs; with the failpoint around only the 05367_embedded query the old test prints the CI diff, 20/20.
  • 50 randomized runs in this configuration and 50 in the default one: 100/100 pass.

🤖 Generated with Claude Code


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

Version info

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

…licas

The last query read TextIndexPositionsBlocksRead/BytesRead only from the
initiator's query_log row (current_database = currentDatabase()). The
counters are incremented by the replica that reads the granule. In the
ParallelReplicas configuration the merged part has a single mark, and a
remote replica sometimes reads it; that replica's QueryFinish row has
current_database = 'default' and is_initial_query = 0, so the initiator
row showed 0 (3 of ~580 runs of the arm_binary ParallelReplicas check).

Sum the counters over every QueryFinish row that shares the initiator's
initial_query_id, as 05232_text_index_lazy_intersection_block_span_rule
does. A replica logs QueryFinish before it sends EndOfStream, so SYSTEM
FLUSH LOGS makes every replica row visible. The tested queries and the
reference are unchanged.

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

groeneai commented Nov 5, 2026

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 my own cold review (2 nits, no code change).

# Sev Finding Verdict Evidence / action
1 💡 Failure tally in the description was stale (3 runs) AGREE CIDB shows 4 failures in 651 runs; description updated
2 💡 A no-parallel-replicas tag would also stop the failure DISAGREE The summed oracle is the shape 10 text-index tests use (0 failures in ~9800 runs each of this check); the tag would drop the test's parallel-replicas coverage

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

Session id: cron:clickhouse-review-slot-8:20261105-200200

@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Local three-replica ParallelReplicas copy with parallel_replicas_local_plan=0 fails the old test 20/20; the failpoint slowdown_parallel_replicas_local_plan_read around only the 05367_embedded query prints the CI diff 20/20.
b Root cause explained? Yes. The oracle read TextIndexPositions* only from the initiator's query_log row, while the counters are incremented on the replica that reads the single mark (its row has current_database = 'default').
c Fix matches root cause? Yes. The counters are summed over every QueryFinish row of the measured query, as in 05232_text_index_lazy_intersection_block_span_rule; no tag, no setting pin.
d Test intent preserved / new tests added? Yes. Queries and reference unchanged, parallel replicas coverage kept; keeping only initiator rows in the new query fails 20/20.
e Both directions demonstrated? Yes. local_plan = 0: old 20/20 fail, new 20/20 pass; failpoint + randomized settings: old fails in exactly the 52/80 remote-read runs, new passes 80/80 (43 such runs).
f Fix is general across code paths? Yes. The other test of #125630 reads no query_log; other text-index ProfileEvents tests skip parallel replicas or already aggregate over initial_query_id.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test oracle fix); local plan 0 and 1, parallel replicas on and off, and 100/100 randomized runs pass.
h Backward compatible? (maintainer-approved exception only) N/A. Test-only change.
i Invariants and contracts preserved? Yes. A replica logs QueryFinish before sending EndOfStream, so SYSTEM FLUSH LOGS query_log makes all rows visible; a replica without a task contributes 0.

Session id: cron:clickhouse-impl-slot-4:20261105-191600

@clickhouse-gh

clickhouse-gh Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9adab12]

Summary: ✅


AI Review

Summary

The PR fixes the flaky 05367_text_index_embedded_positions assertion by identifying initiator queries in the test database and summing TextIndexPositionsBlocksRead and TextIndexPositionsBytesRead across matching initial_query_id rows. This includes replica reads while preserving the existing zero/nonzero assertions and parallel-replica coverage. No actionable findings. The changed test passes in Fast test CI; the author documents forced-remote and randomized before/after reproductions. Tests were not rerun locally because this checkout has no ClickHouse binary or build directory.

Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 5, 2026
@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

cc @ahmadov, could you review this and add the can be tested label so CI runs? Under parallel replicas a remote replica can read the single mark, and its query_log row has current_database = 'default', so the test now sums TextIndexPositions* over all rows of the same initial_query_id.

@clickhouse-gh clickhouse-gh Bot added can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 5, 2026
@alexey-milovidov alexey-milovidov self-assigned this Nov 6, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 6, 2026
Merged via the queue into ClickHouse:master with commit a903fa7 Nov 6, 2026
547 of 549 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 6, 2026
@clickhouse-gh clickhouse-gh Bot added comp-text-index Full-text search: inverted/text index in MergeTree (tokenizers, posting lists, GIN-style index bu... 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-text-index Full-text search: inverted/text index in MergeTree (tokenizers, posting lists, GIN-style index bu... 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