[PR #2359] [MERGED] Add write lock for peer when saving its connection status #19298

Closed
opened 2026-08-05 05:05:50 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/2359
Author: @mlsmaycon
Created: 7/31/2024
Status: Merged
Merged: 7/31/2024
Merged by: @pascal-fischer

Base: mainHead: fix/save-peer-status-inconsistency


📝 Commits (3)

  • 94e3e52 rename lock methods
  • c63c3f8 add write lock by peer key and use read account locks
  • 3c23dff rename accountLocks to resourceLocks and moved peer lock

📊 Changes

15 files changed (+93 additions, -87 deletions)

View changed files

📝 management/server/account.go (+16 -12)
📝 management/server/dns.go (+2 -2)
📝 management/server/event.go (+1 -1)
📝 management/server/file_store.go (+10 -10)
📝 management/server/group.go (+8 -8)
📝 management/server/integrated_validator.go (+1 -1)
📝 management/server/nameserver.go (+5 -5)
📝 management/server/peer.go (+7 -7)
📝 management/server/policy.go (+4 -4)
📝 management/server/posture_checks.go (+4 -4)
📝 management/server/route.go (+5 -5)
📝 management/server/setupkey.go (+4 -4)
📝 management/server/sql_store.go (+11 -9)
📝 management/server/store.go (+4 -4)
📝 management/server/user.go (+11 -11)

📄 Description

Describe your changes

This pull request adds a write lock mechanism for peers when saving their connection status. The primary goal is to ensure thread safety and prevent race conditions during peer status updates.

Key Changes

  • Implemented write locks for peers by their key.
  • Utilized read account locks for methods used by grpcServer.Sync.
  • Renamed lock methods for clarity.

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/2359 **Author:** [@mlsmaycon](https://github.com/mlsmaycon) **Created:** 7/31/2024 **Status:** ✅ Merged **Merged:** 7/31/2024 **Merged by:** [@pascal-fischer](https://github.com/pascal-fischer) **Base:** `main` ← **Head:** `fix/save-peer-status-inconsistency` --- ### 📝 Commits (3) - [`94e3e52`](https://github.com/netbirdio/netbird/commit/94e3e5271c8756abda388ef03c93d02137c9524b) rename lock methods - [`c63c3f8`](https://github.com/netbirdio/netbird/commit/c63c3f81e2148ee36febc63ac738ba844357bfa8) add write lock by peer key and use read account locks - [`3c23dff`](https://github.com/netbirdio/netbird/commit/3c23dfffb493bc4d5a1181d2add7890a01b5ae4d) rename accountLocks to resourceLocks and moved peer lock ### 📊 Changes **15 files changed** (+93 additions, -87 deletions) <details> <summary>View changed files</summary> 📝 `management/server/account.go` (+16 -12) 📝 `management/server/dns.go` (+2 -2) 📝 `management/server/event.go` (+1 -1) 📝 `management/server/file_store.go` (+10 -10) 📝 `management/server/group.go` (+8 -8) 📝 `management/server/integrated_validator.go` (+1 -1) 📝 `management/server/nameserver.go` (+5 -5) 📝 `management/server/peer.go` (+7 -7) 📝 `management/server/policy.go` (+4 -4) 📝 `management/server/posture_checks.go` (+4 -4) 📝 `management/server/route.go` (+5 -5) 📝 `management/server/setupkey.go` (+4 -4) 📝 `management/server/sql_store.go` (+11 -9) 📝 `management/server/store.go` (+4 -4) 📝 `management/server/user.go` (+11 -11) </details> ### 📄 Description ## Describe your changes This pull request adds a write lock mechanism for peers when saving their connection status. The primary goal is to ensure thread safety and prevent race conditions during peer status updates. Key Changes - Implemented write locks for peers by their key. - Utilized read account locks for methods used by grpcServer.Sync. - Renamed lock methods for clarity. ## Issue ticket number and link ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 05:05:50 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#19298