pool: Use timeout for context cancelling

Signed-off-by: Alex Vanin <a.vanin@yadro.com>
This commit is contained in:
Alexey Vanin 2023-10-10 11:39:29 +03:00
parent ca57c8f442
commit 308bdcc2f5

View file

@ -198,7 +198,11 @@ func (p *Pool) Dial(ctx context.Context) error {
clients := make([]client, len(nodes)) clients := make([]client, len(nodes))
for j, node := range nodes { for j, node := range nodes {
clients[j] = newTreeClient(node.Address(), p.dialOptions...) clients[j] = newTreeClient(node.Address(), p.dialOptions...)
if err := clients[j].dial(ctx); err != nil {
tctx, cancel := context.WithTimeout(ctx, p.rebalanceParams.nodeRequestTimeout)
err := clients[j].dial(tctx)
cancel()
if err != nil {
p.log(zap.WarnLevel, "failed to dial tree client", zap.String("address", node.Address()), zap.Error(err)) p.log(zap.WarnLevel, "failed to dial tree client", zap.String("address", node.Address()), zap.Error(err))
continue continue
} }