Repository navigation
fix(admin): wait before scanning memory purge index - #1404
andreclaro wants to merge 2 commits into
Conversation
Ristretto Set/SetWithTTL return once the write is buffered, and trackKey runs at that point. DeleteByPattern used Get as a liveness check and untracked misses, so a concurrent purge (including dryRun) could drop a not-yet-applied key from hashIndex permanently. Flush buffered Sets with Wait first, and stop using Get for liveness — OnEvict/OnReject already clean the index, and Del on a missing orphan is a no-op.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Graphify reviews are paused for this workspace because nobody has used it in 7 days. A workspace owner can resume reviews from the Repositories page: https://app.graphify.com/erpc/repositories |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 696eac7580
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // runs at that point. A Get-based liveness check in that window would miss | ||
| // and untrack the key permanently (OnEvict/OnReject never fire for a key | ||
| // that was never applied). Del on a missing orphan is a no-op. | ||
| m.cache.Wait() |
There was a problem hiding this comment.
Keep orphan cleanup after
Wait
When a buffered Set is rejected or evicted before Set calls trackKey, its callback can delete the index entry first, leaving trackKey to add a stale entry afterward; the previous liveness check handled this Set↔OnEvict race. Wait() drains pending writes but does not repair such orphans, so the scan can count missing keys as matched or deleted, including in dry-run results. Retain a liveness check that does not record a cache hit, or otherwise synchronize index updates with eviction callbacks.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — kept Wait(), restored orphan cleanup with GetTTL (no TinyLFU/hit metrics). Pushed in the latest commit.
Wait() drains buffered Sets so a liveness check no longer false-misses keys that are still applying. Restore orphan cleanup with GetTTL (not Get) so Set↔OnEvict/OnReject stale index entries are dropped without bumping TinyLFU frequency or hit metrics, keeping dry-run counts honest.
Summary
MemoryConnector.DeleteByPatterntreated a RistrettoGetmiss as proof thekey was gone and removed it from
hashIndex.Set/SetWithTTLonly bufferthe write, and
trackKeyruns at buffer time, so a concurrent purge(including
dryRun) could permanently drop a live key from the index.Flush pending Sets with
Wait()before scanning, and stop usingGetforliveness.
OnEvict/OnRejectalready keep the index in sync;Delon amissing orphan is a no-op. Avoiding
Getalso prevents dry-run from bumpingTinyLFU frequency / hit metrics.
Test plan
go build ./data/...go test ./data/ -run 'TestMemory|TestMatchUnsuffixed|TestHoldPurge|TestPurgeConnectors|TestBuildPurge|TestGlob|TestPhysicalKey|TestRvi'Made with Cursor