Skip to content

Fix race condition between insert_new and lookup in ETS hit/5#175

Merged
epinault merged 1 commit intomasterfrom
fix/ets-hit-race-condition
Mar 26, 2026
Merged

Fix race condition between insert_new and lookup in ETS hit/5#175
epinault merged 1 commit intomasterfrom
fix/ets-hit-race-condition

Conversation

@epinault
Copy link
Copy Markdown
Contributor

Handle the case where an ETS entry is deleted between insert_new and lookup calls in TokenBucket.hit/5 and LeakyBucket.hit/5. This could occur during cleanup races or ETS owner process restarts, causing a MatchError on the empty list. Now gracefully re-inserts a fresh entry when lookup returns [].

Closes #173

Handle the case where an ETS entry is deleted between insert_new and
lookup calls in TokenBucket.hit/5 and LeakyBucket.hit/5. This could
occur during cleanup races or ETS owner process restarts, causing a
MatchError on the empty list. Now gracefully re-inserts a fresh entry
when lookup returns [].

Closes #173
@epinault epinault merged commit 801c1b9 into master Mar 26, 2026
9 checks passed
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.

Race condition between insert_new and lookup causes MatchError

1 participant