From cc60ec8d3cb068b32105c7420f768c6b6db29f48 Mon Sep 17 00:00:00 2001 From: Rob Murray Date: Wed, 11 Jun 2025 12:05:40 +0100 Subject: [PATCH] Revert "libn/networkdb: stop table events from racing network leaves" This reverts commit 270a4d41dc1a127802e041415c3c82b0bfc2e559. Signed-off-by: Rob Murray --- libnetwork/networkdb/delegate.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libnetwork/networkdb/delegate.go b/libnetwork/networkdb/delegate.go index 9aa876058f..d909bcdb42 100644 --- a/libnetwork/networkdb/delegate.go +++ b/libnetwork/networkdb/delegate.go @@ -148,13 +148,8 @@ func (nDB *NetworkDB) handleTableEvent(tEvent *TableEvent, isBulkSync bool) bool // Update our local clock if the received messages has newer time. nDB.tableClock.Witness(tEvent.LTime) - nDB.Lock() - // Hold the lock until after we broadcast the event to watchers so that - // the new watch receives either the synthesized event or the event we - // broadcast, never both. - defer nDB.Unlock() - // Ignore the table events for networks that are in the process of going away + nDB.RLock() networks := nDB.networks[nDB.config.NodeID] network, ok := networks[tEvent.NetworkID] // Check if the owner of the event is still part of the network @@ -166,12 +161,18 @@ func (nDB *NetworkDB) handleTableEvent(tEvent *TableEvent, isBulkSync bool) bool break } } + nDB.RUnlock() if !ok || network.leaving || !nodePresent { // I'm out of the network OR the event owner is not anymore part of the network so do not propagate return false } + nDB.Lock() + // Hold the lock until after we broadcast the event to watchers so that + // the new watch receives either the synthesized event or the event we + // broadcast, never both. + defer nDB.Unlock() var entryPresent bool prev, err := nDB.getEntry(tEvent.TableName, tEvent.NetworkID, tEvent.Key) if err == nil {