netbird
netbird copied to clipboard
[management] Stop using locking share for read calls to avoid deadlocks
Describe your changes
This PR removes shared locking on read operations to avoid deadlocks and adds a GORM index on the UserID field in the Peer model.
- Swapped all
store.LockingStrengthShareusages forstore.LockingStrengthNoneon read calls. - Added a GORM index tag to
Peer.UserIDfor improved lookup performance.
We've seen a few deadlock reports for queries with and without transactions that only needed to read data. This Pr removes the locking for share usage and left only the locking for update in use.
Issue ticket number and link
Stack
Checklist
- [x] Is it a bug fix
- [ ] Is a typo/documentation fix
- [x] Is a feature enhancement
- [ ] It is a refactor
- [ ] Created tests that fail without the change (if possible)
- [ ] Extended the README / documentation, if necessary
By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.