mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2026-10-28 16:18:23 +08:00
`test_correction_follows_measurement` needs its baseline sample to hold no retained pages, and takes it right after `SYSTEM JEMALLOC PURGE`. That purge is not guaranteed to reach every arena: `pac_decay_to_limit` returns without purging an arena whose `decay->purging` flag is set (`contrib/jemalloc/src/pac.c:581`), and jemalloc's background thread holds that flag while it decays the pages the previous test's ten queries freed 0.6 s earlier. On master `a0bb275ec76f` the first purge left about 334 MB that the second purge removed (MemoryTracking before/after/purged 498/430/164 MB, the plain counter constant at 113 MB), the query reused those pages, and `gap_after - gap_before > 64 MiB` failed. With `dirty_decay_ms:-1` nothing purges dirty pages automatically (`pac_maybe_decay_purge` returns before `pac_decay_to_limit` on a negative decay), so on this node they leave only through forced full purges: both purges of the test take full effect, and the "after" sample keeps every freed page instead of depending on the 5 s decay. Same approach as `test_dirty_pages_force_purge`. `instance_env_variables=True` keeps the variable out of the cluster-wide env file, so `node` still runs with the default decay. Locally, with CI's 16 per-CPU arenas, 4 of 150 first purges left 108-652 MB of dirty pages with the default decay and 0 of 150 with `dirty_decay_ms:-1`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>