Skip to content

Make test_dirty_pages_force_purge deterministic - #113906

Closed
alexey-milovidov wants to merge 1 commit into
masterfrom
fix/test-dirty-pages-force-purge-flaky
Closed

alexey-milovidov wants to merge 1 commit into
masterfrom
fix/test-dirty-pages-force-purge-flaky

Conversation

@alexey-milovidov

Copy link
Copy Markdown
Member

The test waits for a MemoryAllocatorPurge event, but the purge fires only when jemalloc dirty pages exceed memory_worker_purge_dirty_pages_threshold_ratio (0.2) of max_server_memory_usage (4Gi) = 0.8 GiB. A single test query dirties only ~400 MB, and jemalloc reuses freed extents within an arena, so repeating the same query does not accumulate dirty pages beyond one query's footprint per arena. Crossing the threshold therefore depended on queries landing on different thread-pool threads (= different arenas), and when they did not, the test timed out waiting for the event — 7 failures across unrelated PRs (#113192, #110188, #110144, #111332, …) in the last 14 days per CIDB. Example: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113042&sha=9a329692501a39e051b9c908b281282f4110e0fb&name_0=PR on #113042.

Lower the ratio in the test config so the dirty pages of a single query reliably cross the threshold. Verified locally: the test now passes in ~7 s (the purge fires on the first query) instead of looping.

Related: #113042

Changelog category (leave one):

  • CI Fix or improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

The purge fires only when jemalloc dirty pages exceed
`memory_worker_purge_dirty_pages_threshold_ratio` (0.2) of
`max_server_memory_usage` (4Gi) = 0.8 GiB, but a single test query dirties
only ~400 MB and jemalloc reuses freed extents within an arena, so repeating
the same query does not accumulate dirty pages beyond one query's footprint
per arena. Crossing the threshold therefore depended on queries landing on
different thread-pool threads (= different arenas), and the test timed out
waiting for the `MemoryAllocatorPurge` event when they did not — 7 failures
across unrelated PRs in the last 14 days.

Lower the ratio so a single query reliably crosses the threshold.

Seen in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113042&sha=9a329692501a39e051b9c908b281282f4110e0fb&name_0=PR on #113042

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e3eab12]

Summary: ✅


AI Review

Summary

This PR lowers memory_worker_purge_dirty_pages_threshold_ratio in the integration-test-only config for test_dirty_pages_force_purge so a single query reliably crosses the dirty-page purge threshold instead of depending on work being spread across multiple jemalloc arenas. I reviewed the PR metadata, prior discussion, CI status, the changed config, the full test, and the relevant MemoryWorker purge logic; I did not find a substantiated correctness, safety, or coverage issue in the current PR state.

Final Verdict

✅ No findings.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Closing as a duplicate of #113811, which was opened earlier, applies the same fix (lowering memory_worker_purge_dirty_pages_threshold_ratio in the test's overrides.yaml so a single test query reliably crosses the dirty-pages purge threshold), and is already fully green with an AI review verdict of "No findings".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant