[#9999] evacuate: Add read timeout

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-09-18 18:10:32 +03:00
parent 9d1c915c42
commit ab34637c06
2 changed files with 22 additions and 1 deletions

BIN
go.sum

Binary file not shown.

View file

@ -7,6 +7,7 @@ import (
"strings" "strings"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
@ -642,7 +643,27 @@ func (e *StorageEngine) evacuateObjects(ctx context.Context, sh *shard.Shard, to
var getPrm shard.GetPrm var getPrm shard.GetPrm
getPrm.SetAddress(addr) getPrm.SetAddress(addr)
getRes, err := sh.Get(ctx, getPrm) var getRes shard.GetRes
var err error
done := make(chan interface{})
go func() {
defer func() {
close(done)
}()
getRes, err = sh.Get(ctx, getPrm)
}()
timer := time.NewTimer(30 * time.Second)
select {
case <-ctx.Done():
return ctx.Err()
case <-timer.C:
err = errors.New("failed to read object by timeout")
case <-done:
}
if err != nil { if err != nil {
if prm.IgnoreErrors { if prm.IgnoreErrors {
res.objFailed.Add(1) res.objFailed.Add(1)