-
Notifications
You must be signed in to change notification settings - Fork 527
change topicArns to map safe for concurrent access #3459
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
change topicArns to map safe for concurrent access #3459
Conversation
Thanks for this PR. Can you please replace the usage of the xsync package with Go's sync.Map? It has the same methods. https://pkg.go.dev/golang.org/x/sync/syncmap |
@yaron2 sure, I opted for xsync just because I saw it being used in topicsLocker. Also, I saw |
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.
In this file we were doing synchronization using a mutex. For example, calls to getOrCreateTopic
are wrapped around a lock:
components-contrib/pubsub/aws/snssqs/snssqs.go
Lines 762 to 763 in 95a0a13
s.topicsLocker.Lock(req.Topic) | |
defer s.topicsLocker.Unlock(req.Topic) |
Rather than changing topicArns
, it may make more sense to just ensure that wherever the access to the map was happening that wasn't wrapped in a log (and was causing the panic), uses the lock instead
@ItalyPaleAle so I did something similar to what is done in the The way it is now, caller of |
@nenikola thanks for making the change. I think adding a requirement to have a lock before calling a method is not an unusual thing. It is especially helpful in some cases such as when the caller may invoke the method twice. However perhaps we could add a comment to |
@ItalyPaleAle sounds good, let me add comment and then merge the changes. Thanks! |
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.
Thank you for this contribution and for fixing the issue!
@holopin-bot @nenikola Thank you Nikola! |
Congratulations @nenikola, the maintainer of this repository has issued you a badge! Here it is: https://holopin.io/claim/clzv9vq4q125210cjyqv675ud2 This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account. |
Description
Changed native map to xsync.MapOf which is safe for concurrent access
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #3430
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: