graph/db: fix race in DisconnectBlockAtHeight cache access
The DisconnectBlockAtHeight method was modifying the rejectCache and chanCache without holding the cacheMu lock. This caused races with other operations that properly held the lock, such as AddChannelEdge which modifies the caches in its OnCommit callback while the batch scheduler holds cacheMu. Fix by acquiring cacheMu before removing channels from the caches.
This commit is contained in:
1 file changed
+2
@@ -2911,10 +2911,12 @@ func (s *SQLStore) DisconnectBlockAtHeight(height uint32) (
|
||||
"height: %w", err)
|
||||
}
|
||||
|
||||
s.cacheMu.Lock()
|
||||
for _, channel := range removedChans {
|
||||
s.rejectCache.remove(channel.ChannelID)
|
||||
s.chanCache.remove(channel.ChannelID)
|
||||
}
|
||||
s.cacheMu.Unlock()
|
||||
|
||||
return removedChans, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user