Skip to content

Fix flaky test_writes_split_offsets_read_by_spark - #127787

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-test-writes-split-offsets-read-by-spark
Oct 28, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-test-writes-split-offsets-read-by-spark

Conversation

@groeneai

@groeneai groeneai commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #125619

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

test_storage_iceberg_with_spark/test_writes_split_offsets.py::test_writes_split_offsets_read_by_spark fails its precondition assert len(expected) == 10 with assert 9 == 10 in about 0.5% of runs: on master (report) and on an unrelated PR (report).

The integration harness randomizes max_block_size (8000 to 100000, half of the runs). Parquet does not prefer large blocks, so the INSERT SELECT squashing uses max_block_size as its minimum and numbers(10000) reaches the Iceberg sink as two chunks, M and 10000 - M rows. The Parquet writer forms row groups per chunk, so for M in [8001, 8999] the file has 8 + 1 = 9 row groups.

The test now checks that there are several row groups and still compares Spark's split_offsets with the real row-group offsets, the same change 6962e76 made for 05395_iceberg_write_split_offsets.

Validation: a clickhouse local sweep gives 9 row groups for every M in [8001, 8999] and 10 elsewhere; both CI failure offset arrays match M in 8209..8216 and 8225..8232 byte for byte. The integration test with max_block_size forced to 8001, 8500 and 8999 fails 9 == 10 before the change and passes after it; 9500 and three normal random draws pass.

🤖 Generated with Claude Code


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

Version info

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

The integration harness randomizes `max_block_size` (8000..100000, p=0.5).
Parquet is not a "prefers large blocks" format, so the INSERT SELECT
squashing uses `max_block_size` as its minimum and `numbers(10000)` reaches
the Iceberg sink as two chunks, M and 10000-M rows. The Parquet writer forms
row groups per chunk, so for M in [8001, 8999] the file has 8 + 1 = 9 row
groups instead of 10, and the precondition `len(expected) == 10` fails.

Check that there are several row groups and keep the strict `split_offsets`
comparison, the same as 6962e76 did for 05395_iceberg_write_split_offsets.

Master failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=1c6ae3a087fc4a6471182c0be402acf0f32a81b3&name_0=MasterCI&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%203%2F4%29

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 (0 findings).
Checked: the randomized max_block_size mechanism against InterpreterInsertQuery.cpp and ParquetBlockOutputFormat::consume, the remaining assertions of the test (one data file, strict split_offsets equality), and the sibling tests that assert row-group counts.

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

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

Session id: cron:clickhouse-review-slot-9:20261025-173900

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. With the harness draw forced to max_block_size = 8500 (also 8001, 8999), the unchanged test fails assert 9 == 10 on every run.
b Root cause explained? A random max_block_size M in [8001, 8999] makes numbers(10000) reach the Iceberg sink as two chunks (M, 10000 - M). The Parquet writer forms row groups per chunk: 8 + 1 = 9, so the exact-count precondition fails. A clickhouse local sweep gives 9 groups for all 999 values and 10 elsewhere; both CI offset arrays match byte for byte.
c Fix matches root cause? Yes. The exact count is an artifact of chunking, not of split_offsets; the precondition now requires several row groups and the split_offsets equality is unchanged. Same change as 6962e76 for 05395_iceberg_write_split_offsets.
d Test intent preserved / new tests added? Yes. The test still compares Spark's split_offsets with the real row-group offsets, and > 1 still fails when output_format_parquet_row_group_size does not reach the writer (1 row group, checked). Test-only change.
e Both directions demonstrated? Yes. Forced 8001 / 8500 / 8999: FAIL before, PASS after; 9500 and three normal random draws PASS after.
f Fix is general across code paths? N/A (test-only). The sibling test in the same file and 05395 already check > 1; no other integration test asserts an exact row-group count.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes for the harness domain: every M in [8000, 9000] plus 9500, 9999, 10000, 65409 locally, and forced/random draws in the integration test.
h Backward compatible? (maintainer-approved exception only) N/A (test-only, no setting or format change).
i Invariants and contracts preserved? N/A for engine code; the test's own checks (one data file, split_offsets equal to row-group offsets) are unchanged.

Session id: cron:clickhouse-impl-slot-5:20261025-172300

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @hanfei1991, could you review this and add the can be tested label so CI runs? The integration harness randomizes max_block_size, and for values in [8001, 8999] numbers(10000) reaches the Parquet writer as two chunks, giving 9 row groups instead of 10; the test now asserts several row groups and keeps the strict split_offsets comparison, the same change 6962e76 made for 05395.

@clickhouse-gh

clickhouse-gh Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0cf078b]

Summary: ✅


AI Review

Summary

This PR fixes a flaky precondition in test_writes_split_offsets_read_by_spark by allowing the Parquet row-group count to vary with randomized max_block_size. It retains the requirement for multiple row groups and exact equality between Spark's split_offsets and the offsets read independently by PyArrow. No actionable findings.

Final Verdict

Status: ✅ Approve

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 28, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 28, 2026
Merged via the queue into ClickHouse:master with commit 1230fe6 Oct 28, 2026
526 of 528 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 28, 2026
@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... 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-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... 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