Skip to content

extenddb-cache: refresh_dropped_when_hard_miss_races fails when its last read starts a refresh #877

Open

Description

@LeeroyHannigan

What is wrong

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:

  1. The hard miss at about 250 ms stores the entry for n=3 (loader call 3).
  2. 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.
  3. 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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions