[#2210] services/tree: Drop messages not in queue

Currently, under high load clients are blocked on channel send
and the number of goroutines can increase indefinitely.
In this commit we drop replication messages if send/recv queue is full
and rely on a background synchronization.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
remotes/carpawell/fix/multiple-cache-update-requests-FROST
Evgenii Stratonikov 2023-01-20 18:04:20 +03:00 committed by fyrchik
parent 25d5995cef
commit 67c97c6804
2 changed files with 5 additions and 2 deletions

View File

@ -148,7 +148,7 @@ func (s *Service) pushToQueue(cid cidSDK.ID, treeID string, op *pilorama.LogMove
treeID: treeID,
op: op,
}:
case <-s.closeCh:
default:
}
}

View File

@ -485,7 +485,8 @@ func (s *Service) Apply(_ context.Context, req *ApplyRequest) (*ApplyResponse, e
return nil, fmt.Errorf("can't parse meta-information: %w", err)
}
s.replicateLocalCh <- applyOp{
select {
case s.replicateLocalCh <- applyOp{
treeID: req.GetBody().GetTreeId(),
CIDDescriptor: pilorama.CIDDescriptor{CID: cid, Position: pos, Size: size},
Move: pilorama.Move{
@ -493,6 +494,8 @@ func (s *Service) Apply(_ context.Context, req *ApplyRequest) (*ApplyResponse, e
Child: op.GetChildId(),
Meta: meta,
},
}:
default:
}
return &ApplyResponse{Body: &ApplyResponse_Body{}, Signature: &Signature{}}, nil
}