Skip to content

Fix flaky 02968_file_log_multiple_read: wait for all rows before reading them - #126074

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-flaky-02968-wait-all-rows
Oct 16, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-flaky-02968-wait-all-rows

Conversation

@groeneai

@groeneai groeneai commented Oct 15, 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):

Not required.

Description

Related: #125135

Failures: Stateless tests (arm_binary, s3 storage, DBReplicated, sequential) on #125135 (output stops at 18) and #125433 (stops at 19).

The test waited for count() >= 1 before the first SELECT (10 rows expected) and for count() >= 11 before the second (20 rows expected), which only proves that one FileLog batch was committed. The second round appends lines 1..20 with 20 separate echos, so a batch can start in the middle of the loop and read only a prefix; the remaining lines arrive in the next batch. In the failing job's server log, the part with ids 11..18 was committed at 11.433, the test's count() saw 18 at 11.443, its SELECT printed 1..18 at 11.518, and the part with 19 and 20 was committed at 11.617. No rows were lost.

The waits now require every row the following SELECT prints (10 and 20).

Validation with a master debug binary, on local disk and on s3-backed MergeTree with --replicated-database:

  • With lines 19 and 20 written 5 s after the others, the old thresholds print 1..18 in 5/5 runs, as in CI; the new ones pass 5/5.
  • 50/50 randomized runs on each storage; runtime unchanged (~1.7 s).

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

Version info

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

…ing them

The waits before the two SELECTs required `count() >= 1` and `count() >= 11`,
which only proves that one FileLog batch was committed. The second round
appends lines 1..20 with separate writes, so a batch can start in the middle
of the loop and read a prefix, with the rest arriving in the next batch. On
`Stateless tests (arm_binary, s3 storage, DBReplicated, sequential)` the
SELECT then ran between the part with 11..18 and the part with 19, 20, and
printed 1..18 (PR ClickHouse#125135) or 1..19 (PR ClickHouse#125433).

Wait for every row the following SELECT prints instead (10 and 20).

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 my own cold review of the diff (0 findings).

No findings to adjudicate. Checked: both new thresholds equal the row counts in the .reference (10, 20); duplicates would still fail on the reference diff and lost rows now fail with the explicit timeout message; the read-up-to-snapshot behaviour the race depends on is FileLogConsumer::readNewRecords stopping at last_open_end.

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

Session id: cron:clickhouse-review-slot-9:20261015-165500

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Writing lines 19 and 20 of round 2 five seconds after the others makes the old thresholds print 1..18 in 5/5 runs on local disk and 5/5 on s3-backed MergeTree with --replicated-database (diff -19, -20, as in CI).
b Root cause explained? The waits (count() >= 1, count() >= 11) proved one FileLog batch, not all rows. A batch that starts while the append loop is running reads a prefix; in the failing job's server log the SELECT ran between the part with 11..18 and the part with 19, 20.
c Fix matches root cause? Yes. Each wait now requires the rows the next SELECT prints (10, 20). No timeout, tag or data change.
d Test intent preserved / new tests added? Yes. The test still checks re-reading an appended file through the MV filter; duplicates still fail on the reference diff, and lost rows now fail with the explicit timeout message instead of a truncated output.
e Both directions demonstrated? Yes, with the repro from (a): old thresholds FAIL 5/5, new PASS 5/5, on both storages.
f Fix is general across code paths? The other FileLog tests with a count wait already wait for the full expected count; this was the only one waiting for a single batch.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only change). 50/50 randomized runs on local disk and 50/50 on s3 + Replicated database.
h Backward compatible? (maintainer-approved exception only) N/A (test-only change).
i Invariants and contracts preserved? N/A (no src/ change).

Session id: cron:clickhouse-impl-slot-41:20261015-163700

@clickhouse-gh

clickhouse-gh Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a1e4556]

Summary: ✅


AI Review

Summary

The PR fixes a race in 02968_file_log_multiple_read by waiting for all 10 initial rows and all 20 cumulative rows before each output assertion. The linked CI failures and FileLog file-size snapshot behavior support the diagnosis; the PR also reports successful delayed-tail reproductions and repeated validation on local and S3-backed storage. No actionable findings.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 15, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @kssenii, could you review this? Test-only: the waits in 02968_file_log_multiple_read now require all 10 and 20 rows instead of one FileLog batch, so the SELECT no longer races the batch that commits lines 19 and 20.

@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 15, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 15, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 16, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 16, 2026
Merged via the queue into ClickHouse:master with commit 5f78a86 Oct 16, 2026
526 of 528 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 16, 2026
@clickhouse-gh clickhouse-gh Bot added comp-message-queues Message queue integrations (Kafka, RabbitMQ, NATS table engines for stream ingestion/egress). 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-message-queues Message queue integrations (Kafka, RabbitMQ, NATS table engines for stream ingestion/egress). 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