Repository navigation
test(cache): sample metrics before final read in refresh_dropped_when_hard_miss_races - #881
Draft
Dodothereal wants to merge 1 commit into
Draft
Dodothereal wants to merge 1 commit into
Dodothereal wants to merge 1 commit into
Conversation
…_hard_miss_races Fixes ExtendDB#877. In refresh_dropped_when_hard_miss_races, read the metrics snapshot immediately after the slow refresh finishes rather than after reading the post-hard-miss value. Because soft_ttl is 50ms and the post- hard-miss entry is ~150ms old at the time of the read, the read was triggering a background refresh that could finish and increment refresh_success before metrics were sampled.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #877. In
crates/cache/src/tests.rs, the testtests::refresh_dropped_when_hard_miss_racesoccasionally failed in CI when its final read (v4) started an asynchronous background refresh that completed beforecache.metrics().snapshot()was called, resulting inrefresh_success == 1instead of0.Because
soft_ttlis 50ms and the post-hard-miss entry (v3) was loaded ~150ms earlier,v4is a stale hit and legitimately triggers a background refresh. Sampling metrics immediately after waiting for the slow refresh (n=2) finishes ensures the assertion only measures the dropped slow refresh.v4is then read immediately after to verify thatn=3was preserved.Validation
cargo fmt --checkpassed.cargo test -p extenddb-cache --libpassed (27 tests passed in 0.42s).Provenance
Prepared with AI assistance (Gemini 3.8 Flash) under contributor authorization. Draft status preserved pending review.