From 280679ac6baa6c7ba3222c1d7885bfd2e0c4ec41 Mon Sep 17 00:00:00 2001 From: Aurora Gaffney Date: Mon, 24 Jun 2024 08:25:48 -0500 Subject: [PATCH] fix: make client block buffer size larger to avoid deadlocks This makes the chainsync per-consumer buffer larger than the possible number of blocks that we can put into it right off the bat on connect to help prevent deadlocks --- chainsync/chainsync.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chainsync/chainsync.go b/chainsync/chainsync.go index b517e3f..2778d1b 100644 --- a/chainsync/chainsync.go +++ b/chainsync/chainsync.go @@ -30,7 +30,8 @@ import ( ) const ( - maxRecentBlocks = 20 // Number of recent blocks to cache + maxRecentBlocks = 20 // Number of recent blocks to cache + clientBlockBufferSize = 50 // Size of per-client block buffer ) var ( @@ -178,7 +179,7 @@ func (s *State) RemoveClientConnId(connId ouroboros.ConnectionId) { } func (s *State) sub(key ouroboros.ConnectionId) chan ChainsyncBlock { - tmpChan := make(chan ChainsyncBlock, maxRecentBlocks) + tmpChan := make(chan ChainsyncBlock, clientBlockBufferSize) if s.subs == nil { s.subs = make(map[ouroboros.ConnectionId]chan ChainsyncBlock) }