-
Notifications
You must be signed in to change notification settings - Fork 54
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
GO-4171: Fix potential race in subscription cache #1690
Conversation
Coverage provided by /~https://github.com/seriousben/go-patch-cover-action |
core/subscription/cache.go
Outdated
@@ -86,13 +88,18 @@ func (e *entry) Get(key string) *types.Value { | |||
|
|||
type cache struct { | |||
entries map[string]*entry | |||
sync.Mutex |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
ad7ee9d
to
6a957ed
Compare
524032f
to
d8aabb6
Compare
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>
https://linear.app/anytype/issue/GO-4171/fix-potential-race-in-subscription-cache