Skip to content

Fix flaky test_dirty_pages_force_purge - #113811

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix/dirty-pages-force-purge-flaky
Aug 9, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix/dirty-pages-force-purge-flaky

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

Related: #110188

The test test_dirty_pages_force_purge occasionally times out waiting for the MemoryAllocatorPurge event (seen on unrelated PRs #110188, #111332, #113192, #107442, #105056; e.g. this report).

Root cause: the test query peaks at ~417 MiB, but the forced purge fires only when jemalloc dirty pages exceed max_server_memory_usage (4 GiB) × memory_worker_purge_dirty_pages_threshold_ratio (0.2) = 819 MiB. Since jemalloc reuses dirty pages within the same arenas across iterations, pdirty can plateau below the threshold when few arenas are touched — for example, when the number of query threads is lowered by MemoryTrackerUtils on a constrained CI machine (the failing run shows Lower number of threads for query to 3 (5 requested) and all 100 iterations peaking at exactly 416.86 MiB) — so the event never fires and the test times out.

Fix: lower the ratio to 0.05 (~205 MiB), so a single iteration of the test query reliably exceeds the threshold. The purge is still attributable to dirty-page volume rather than the total-memory threshold (0.9 × 4 GiB = 3.6 GiB, and the test keeps asserting peak memory < 3 GiB).

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Version info

  • Merged into: 26.8.1.1044 (included in 26.8 and later)

The test query peaks at ~417 MiB, but the purge was triggered only when
jemalloc dirty pages exceeded 4 GiB * 0.2 = 819 MiB. Since jemalloc reuses
dirty pages within the same arenas across iterations, `pdirty` can plateau
below the threshold when few arenas are touched (e.g. when the number of
query threads is lowered by `MemoryTrackerUtils` on a constrained CI
machine), so the `MemoryAllocatorPurge` event never fired and the test
timed out. Lower the ratio to 0.05 (~205 MiB) so a single iteration of the
test query reliably exceeds the threshold.

Seen in: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110188&sha=5b0dd0156a543c7e72ceb73c0ebb890d53cb1f83&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%204%2F4%29
PR: #110188

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

clickhouse-gh Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b87486d]

Summary: ✅


AI Review

Summary

This PR lowers memory_worker_purge_dirty_pages_threshold_ratio in the integration-test config for test_dirty_pages_force_purge from 0.2 to 0.05 so the test query can exceed the dirty-page purge threshold even on CI machines that reduce query parallelism. The referenced failing log supports that rationale: the query was repeatedly reduced to 3 threads, hit 416.86 MiB peak memory on each iteration, and still never observed a MemoryAllocatorPurge event at the old threshold. I did not find a correctness or coverage issue in the current change.

Missing context / blind spots
  • ⚠️ I could not rerun the integration test locally because this checkout does not contain a built ClickHouse binary; the review relies on the current PR CI being green and on the downloaded logs from the referenced failure report.
Final Verdict

No findings.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think it was a good test, but I also don't mind this change.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 9, 2026
@alexey-milovidov
alexey-milovidov requested a review from azat August 9, 2026 18:01
@alexey-milovidov alexey-milovidov self-assigned this Aug 9, 2026
Merged via the queue into master with commit e0bd153 Aug 9, 2026
180 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix/dirty-pages-force-purge-flaky branch August 9, 2026 19:57
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants