Skip to content

Commit a83d117

Browse files
committed
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.
1 parent 550de8d commit a83d117

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

graph/db/sql_store.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,10 +2916,12 @@ func (s *SQLStore) DisconnectBlockAtHeight(height uint32) (
29162916
"height: %w", err)
29172917
}
29182918

2919+
s.cacheMu.Lock()
29192920
for _, channel := range removedChans {
29202921
s.rejectCache.remove(channel.ChannelID)
29212922
s.chanCache.remove(channel.ChannelID)
29222923
}
2924+
s.cacheMu.Unlock()
29232925

29242926
return removedChans, nil
29252927
}

0 commit comments

Comments
 (0)