Skip to content

Fix flaky test_async_metadata_refresh - #130493

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix-flaky-iceberg-async-metadata-refresh
Nov 10, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix-flaky-iceberg-async-metadata-refresh

Conversation

@PedroTadim

@PedroTadim PedroTadim commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

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

test_storage_iceberg_with_spark/test_async_metadata_refresh.py::test_async_metadata_refresh[s3] fails with assert 200 == 100 at the stale-count check after the Spark append.

The table is created with iceberg_metadata_async_prefetch_period_ms = 5000. The background refresher (backgroundMetadataPrefetcherThread) runs every 5 seconds. When it runs between the moment the new metadata lands in S3 and the following SELECT, that SELECT already sees 200 rows. The window grows when the upload and the query are slow, so the failure shows up mostly on sanitizer builds.

This PR adds the iceberg_metadata_prefetch_pause failpoint at the start of backgroundMetadataPrefetcherThread, as suggested in review. The test pauses the refresher (SYSTEM WAIT FAILPOINT ... PAUSE) before the Spark append, checks the stale count of 100, then releases the refresher. Instead of sleeping for two refresh periods, it now polls until the refreshed count of 200 is visible, then checks that the refresher read from S3 (S3ReadRequestsCount grew).

CI history over the last 90 days: 53 failures on master, 24 on release/26.6 (about 1.2% of runs there), all assert 200 == 100. No tracking issue or other fix exists.

🤖 Generated with Claude Code


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

Version info

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

With a 5 s async prefetch period, the refresher can pick up the appended
snapshot between the upload and the SELECT, so the count is already 200.

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

clickhouse-gh Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [33c1a35]

Summary: ✅


AI Review

Summary

The PR adds a failpoint to preserve stale-read coverage in test_async_metadata_refresh and replaces a fixed refresh delay with polling. Request changes: repeated execution can pause a previous table's refresher and leave the original race intact.

Missing context / blind spots
  • ⚠️ Integration tests were not run locally: this checkout has no ClickHouse binary or required Python/Spark dependencies. The current head's Praktika integration jobs are pending; completed runs would close the runtime-validation gap.
Findings

⚠️ Majors

  • test_async_metadata_refresh.py:267: The wait does not establish that the current table's refresher is paused. The failpoint is server-wide and PAUSEABLE_ONCE. Under the documented --count / --repeat-scope=function mode, the package-scoped fixture retains UUID-named tables from earlier repetitions, including their active refresh tasks. An old table can consume the failpoint and satisfy this wait while the current table keeps refreshing, allowing the same 200 == 100 failure. Add DROP TABLE ... SYNC cleanup covering the entire test, after releasing the failpoint, or scope the pause and acknowledgement to the current table.
Tests
  • ⚠️ Verify multiple repetitions of test_async_metadata_refresh[s3] in the same cluster after the fix, preserving both the stale count of 100 and eventual refreshed count of 200.
Final Verdict

Status: ⚠️ Request changes. Ensure the pause applies to the current table and verify repeated execution with the shared fixture.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 10, 2026
@PedroTadim
PedroTadim marked this pull request as draft November 10, 2026 13:03
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Nov 10, 2026
@PedroTadim
PedroTadim marked this pull request as ready for review November 10, 2026 13:12

@antoniofilipovic antoniofilipovic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest different fix if possible, but for sake of unblocking PR, LGTM

@antoniofilipovic antoniofilipovic self-assigned this Nov 10, 2026
@PedroTadim
PedroTadim added this pull request to the merge queue Nov 10, 2026
@PedroTadim
PedroTadim removed this pull request from the merge queue due to a manual request Nov 10, 2026
…tadata_refresh

Add the `iceberg_metadata_prefetch_pause` failpoint at the start of
`backgroundMetadataPrefetcherThread`. The test pauses the refresher before the
Spark append, so the stale-count check is deterministic again, and polls for the
refreshed count instead of sleeping for two refresh periods.

Related: #130493

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

Copy link
Copy Markdown
Member Author

@antoniofilipovic the failpoint is not a lot of code. Let's keep the coverage

# Hold the refresher before it reads the latest metadata, so the next SELECT must see stale data
instance.query("SYSTEM ENABLE FAILPOINT iceberg_metadata_prefetch_pause")
try:
instance.query("SYSTEM WAIT FAILPOINT iceberg_metadata_prefetch_pause PAUSE")

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.

[P2] Ensure the paused refresher belongs to this test's table

iceberg_metadata_prefetch_pause is server-wide and registered as PAUSEABLE_ONCE, so this wait only proves that some Iceberg table paused. With the documented --count / --repeat-scope=function mode, the package-scoped cluster survives between repetitions, and this test never drops its UUID-named table. A previous repetition's refresher can therefore consume the one-shot failpoint; this wait returns while the current table continues refreshing, and the stale-count assertion can still fail with 200 == 100 after the upload. Please drop the table with DROP TABLE ... SYNC in cleanup covering the entire test (after releasing the failpoint), or scope the pause/acknowledgement to the current table, then verify repeated execution in the same cluster.

@clickhouse-gh

clickhouse-gh Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 33c1a3572 with master 2170ef336 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse-keeper ×1.10 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 9.1 s 18.7 s +9.7 s (+108%)
Compile time of recompiled translation units

10 translation units recompiled, 32 s compile time in total, 10 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×1.18 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +1.8 s (+6%) in total before that adjustment.

Job report

@clickhouse-gh clickhouse-gh Bot added comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. and removed comp-testing Test content only (no production code). labels Nov 10, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 10, 2026
Merged via the queue into master with commit 7f0b43d Nov 10, 2026
187 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-flaky-iceberg-async-metadata-refresh branch November 10, 2026 21:10
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 10, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 10, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 11, 2026
Backport #130493 to 26.10: Fix flaky test_async_metadata_refresh
robot-ch-test-poll3 added a commit that referenced this pull request Nov 12, 2026
Cherry pick #130493 to 26.8: Fix flaky test_async_metadata_refresh
robot-ch-test-poll3 added a commit that referenced this pull request Nov 12, 2026
Cherry pick #130493 to 26.9: Fix flaky test_async_metadata_refresh
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 12, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 12, 2026
Backport #130493 to 26.8: Fix flaky test_async_metadata_refresh
clickhouse-gh Bot added a commit that referenced this pull request Nov 12, 2026
Backport #130493 to 26.9: Fix flaky test_async_metadata_refresh
@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.4-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants