[#195] morph: use blocking unlimited pool for notifications
With non-blocking pool restricted by 10 in capacity, the probability of dropping events is unexpectedly big. Notifications are an essential part of the FrostFS, we should not drop anything, especially new epochs. ``` Mar 31 07:07:03 vedi neofs-ir[19164]: 2023-03-31T07:07:03.901Z debug subscriber/subscriber.go:154 new notification event from sidechain {"name": "NewEpoch"} Mar 31 07:07:03 vedi neofs-ir[19164]: 2023-03-31T07:07:03.901Z warn event/listener.go:248 listener worker pool drained {"chain": "morph", "capacity": 10} ``` Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
ed28ce24cd
commit
03bef2bc98
3 changed files with 7 additions and 33 deletions
|
@ -609,11 +609,6 @@ func (l *listener) RegisterBlockHandler(handler BlockHandler) {
|
|||
|
||||
// NewListener create the notification event listener instance and returns Listener interface.
|
||||
func NewListener(p ListenerParams) (Listener, error) {
|
||||
// defaultPoolCap is a default worker
|
||||
// pool capacity if it was not specified
|
||||
// via params
|
||||
const defaultPoolCap = 10
|
||||
|
||||
switch {
|
||||
case p.Logger == nil:
|
||||
return nil, fmt.Errorf("%s: %w", newListenerFailMsg, errNilLogger)
|
||||
|
@ -621,12 +616,9 @@ func NewListener(p ListenerParams) (Listener, error) {
|
|||
return nil, fmt.Errorf("%s: %w", newListenerFailMsg, errNilSubscriber)
|
||||
}
|
||||
|
||||
poolCap := p.WorkerPoolCapacity
|
||||
if poolCap == 0 {
|
||||
poolCap = defaultPoolCap
|
||||
}
|
||||
|
||||
pool, err := ants.NewPool(poolCap, ants.WithNonblocking(true))
|
||||
// The pool here must be blocking, otherwise notifications could be dropped.
|
||||
// The default capacity is 0, which means "infinite".
|
||||
pool, err := ants.NewPool(p.WorkerPoolCapacity)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not init worker pool: %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue