Visitar URL original
fix(admin): wait before scanning memory purge index by andreclaro · Pull Request #1404 · erpc/erpc · GitHub
Skip to content

fix(admin): wait before scanning memory purge index - #1404

Open
andreclaro wants to merge 2 commits into
erpc:mainfrom
andreclaro:fix/memory-purge-wait-before-index-scan
Open

andreclaro wants to merge 2 commits into
erpc:mainfrom
andreclaro:fix/memory-purge-wait-before-index-scan

Conversation

@andreclaro

Copy link
Copy Markdown
Contributor

Summary

MemoryConnector.DeleteByPattern treated a Ristretto Get miss as proof the
key was gone and removed it from hashIndex. Set/SetWithTTL only buffer
the write, and trackKey runs 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 using Get for
liveness. OnEvict/OnReject already keep the index in sync; Del on a
missing orphan is a no-op. Avoiding Get also prevents dry-run from bumping
TinyLFU frequency / hit metrics.

Test plan

  • go build ./data/...
  • go test ./data/ -run 'TestMemory|TestMatchUnsuffixed|TestHoldPurge|TestPurgeConnectors|TestBuildPurge|TestGlob|TestPhysicalKey|TestRvi'

Made with Cursor

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T09:09:01.209311Z 696eac7 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@graphify-labs

graphify-labs Bot commented Nov 5, 2026

Copy link
Copy Markdown

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread data/memory.go
// 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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant