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

GO-4171: Fix potential race in subscription cache #1690

Conversation

Copy link

github-actions bot commented Oct 15, 2024

New Coverage 49.1% of statements
Patch Coverage 96.7% of changed statements (29/30)

Coverage provided by /~https://github.com/seriousben/go-patch-cover-action

@@ -86,13 +88,18 @@ func (e *entry) Get(key string) *types.Value {

type cache struct {
entries map[string]*entry
sync.Mutex
Copy link
Contributor

Choose a reason for hiding this comment

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

should we use the rwmutex and use readlock for get?

Copy link
Member

Choose a reason for hiding this comment

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

you could just lock the whole spaceSubscription in collectionObserver.fetchEntries, the 99% of time the cache is accessed in one goroutine, and it's accessed a lot, so constant locking-unlocking will add performance overhead

btw use feature/chat as target branch

Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
@AnastasiaShemyakinskaya AnastasiaShemyakinskaya force-pushed the go-4171-fix-potential-race-in-subscription-cache branch from ad7ee9d to 6a957ed Compare October 16, 2024 09:48
@AnastasiaShemyakinskaya AnastasiaShemyakinskaya changed the base branch from main to feature/chat October 16, 2024 09:48
@AnastasiaShemyakinskaya AnastasiaShemyakinskaya force-pushed the go-4171-fix-potential-race-in-subscription-cache branch from 524032f to d8aabb6 Compare October 16, 2024 17:00
Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
@AnastasiaShemyakinskaya AnastasiaShemyakinskaya merged commit 6a44819 into feature/chat Oct 17, 2024
5 checks passed
@AnastasiaShemyakinskaya AnastasiaShemyakinskaya deleted the go-4171-fix-potential-race-in-subscription-cache branch October 17, 2024 10:44
@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants