fix: do not notify watchers when deleting an absent key - #21
Merged
Conversation
nmbrone
commented
Sep 2, 2026
Comment on lines
+165
to
+166
| Watchers are notified only when the key was actually present. | ||
|
|
Owner
Author
There was a problem hiding this comment.
Suggested change
| Watchers are notified only when the key was actually present. |
nmbrone
force-pushed
the
fix/delete-absent-key
branch
from
September 2, 2026 07:06
ffe69c9 to
994dee6
Compare
delete/2 broadcast {:deleted, bucket, key} unconditionally, so watchers
were woken for keys that had never been in the bucket. This was also
inconsistent with put_new/3, which stays quiet when it does not write.
Use :ets.take/2 so the removal and the presence check are one atomic
operation, and broadcast only when a key was actually removed.
nmbrone
force-pushed
the
fix/delete-absent-key
branch
from
September 2, 2026 07:08
994dee6 to
4457e69
Compare
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.
delete/2broadcast{:deleted, bucket, key}unconditionally, so watchers were woken for keys that had never been in the bucket. It was also inconsistent withput_new/3, which stays quiet when it does not write.:ets.take/2makes the removal and the presence check one atomic operation, so the broadcast can be conditional at no extra cost over the previous:ets.delete/2.Behaviour change: a watcher that relied on receiving
{:deleted, …}for a key that was not present will no longer get that message.Covered by a test asserting no notification is sent for an absent key.