Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle deletion of cache entry #17

Merged
merged 2 commits into from
Mar 21, 2025
Merged

Correctly handle deletion of cache entry #17

merged 2 commits into from
Mar 21, 2025

Conversation

PapaCharlie
Copy link
Member

See documentation in code for more details, but the high-level problem is that an entry was deleted too early from the cache, orphaning the notification loop. If the same resource gets re-created, it would create a new entry and execute a new notification loop. These two loops would then deliver competing notifiations to subscribers.

See documentation in code for more details, but the high-level problem is that
an entry was deleted too early from the cache, orphaning the notification loop.
If the same resource gets re-created, it would create a new entry and execute a
new notification loop. These two loops would then deliver competing notifiations
to subscribers.
Copy link

@bohhyang bohhyang left a comment

Choose a reason for hiding this comment

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

makes sense! thanks.

// Because the notification loop may still be running from the previous call to Set, the value may be
// still be present in the cache for a short while. However, it is expected to *eventually*
// disappear.
require.Eventually(t, func() bool { return !inCache(c) }, time.Second, time.Millisecond)

Choose a reason for hiding this comment

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

TIL

@PapaCharlie PapaCharlie merged commit 084dcbb into master Mar 21, 2025
2 checks passed
@PapaCharlie PapaCharlie deleted the pc/cancel branch March 21, 2025 22:56
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.

2 participants