Commit 4f7a6228 authored by acud's avatar acud Committed by GitHub

fix(hive): prevent goroutine pileup on validation (#2444)

parent fe6a5919
......@@ -38,6 +38,7 @@ const (
messageTimeout = 1 * time.Minute // maximum allowed time for a message to be read or written.
maxBatchSize = 30
pingTimeout = time.Second * 5 // time to wait for ping to succeed
batchValidationTimeout = 5 * time.Minute // prevent lock contention on peer validation
)
var (
......@@ -246,7 +247,9 @@ func (s *Service) startCheckPeersHandler() {
s.wg.Add(1)
go func() {
defer s.wg.Done()
s.checkAndAddPeers(ctx, newPeers)
cctx, cancel := context.WithTimeout(ctx, batchValidationTimeout)
defer cancel()
s.checkAndAddPeers(cctx, newPeers)
}()
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment