From 58f66818c2ed2fe905c7d8671cd94c442e4122ea Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Wed, 7 May 2025 15:55:49 +0200 Subject: [PATCH] remove write lock on add peer --- management/server/peer.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/management/server/peer.go b/management/server/peer.go index 9ff80442e..5e52bd110 100644 --- a/management/server/peer.go +++ b/management/server/peer.go @@ -474,13 +474,6 @@ func (am *DefaultAccountManager) AddPeer(ctx context.Context, setupKey, userID s return nil, nil, nil, status.Errorf(status.NotFound, "failed adding new peer: account not found") } - unlock := am.Store.AcquireWriteLockByUID(ctx, accountID) - defer func() { - if unlock != nil { - unlock() - } - }() - // This is a handling for the case when the same machine (with the same WireGuard pub key) tries to register twice. // Such case is possible when AddPeer function takes long time to finish after AcquireWriteLockByUID (e.g., database is slow) // and the peer disconnects with a timeout and tries to register again. @@ -657,9 +650,6 @@ func (am *DefaultAccountManager) AddPeer(ctx context.Context, setupKey, userID s am.StoreEvent(ctx, opEvent.InitiatorID, opEvent.TargetID, opEvent.AccountID, opEvent.Activity, opEvent.Meta) - unlock() - unlock = nil - if updateAccountPeers { am.BufferUpdateAccountPeers(ctx, accountID) }