You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
extenddb-cache: refresh_dropped_when_hard_miss_races fails when its last read starts a refresh #877
tests::refresh_dropped_when_hard_miss_races in crates/cache/src/tests.rs fails now and then in CI. It failed in the mongodb-rust job of #355 on 2026-11-06, and once before on #466, with this message:
the slow refresh must NOT have written back; got SwrMetricsSnapshot { hits: 0, stale_hits: 2, misses: 2, negative_hits: 0, refresh_success: 1, refresh_failure: 0, refresh_skipped_inflight: 0, refresh_dropped_epoch: 1, invalidations: 0 }
The cache dropped the slow refresh (loader call 2), as the test expects: refresh_dropped_epoch is 1. The refresh_success of 1 comes from another refresh, which the last read of the test starts:
The hard miss at about 250 ms stores the entry for n=3 (loader call 3).
The last read, at about 400 ms, finds that entry about 150 ms old. soft_ttl is 50 ms, so the read is a stale hit (stale_hits: 2, hits: 0). It starts a background refresh, loader call 4, which returns at once.
The test reads the metrics right after that read. When the background refresh finishes first, refresh_success is 1, and the assertion fails.
The test comment says the entry is "well within the 200ms hard TTL" at the last read. That is true, but the entry is past soft_ttl, so the read is a stale hit.
Where
crates/cache/src/tests.rs, the last read and the metrics assertions of refresh_dropped_when_hard_miss_races.
What to change
Read the metrics snapshot before the last read. The two metric assertions then check only the slow refresh, and the last read still checks that the value is n=3. A larger soft_ttl does not fix it, because step 2 of the test needs a stale hit at 80 ms.
Activity