[#1709] shard: Check if context canceled for shard iteration

If context has already been canceled, then there is no need to check other shards.
At the same time, it is necessary to avoid handling context cancellation
in each handler. Therefore, the context check has been moved to the shard
iteration method, which now returns an error.

Change-Id: I70030ace36593ce7d2b8376bee39fe82e9dbf88f
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2025-04-21 12:13:32 +03:00
parent a27e003508
commit 3a441f072f
Signed by: dstepanov-yadro
GPG key ID: 237AF1A763293BC0
12 changed files with 149 additions and 86 deletions

View file

@ -96,7 +96,7 @@ func (e *StorageEngine) put(ctx context.Context, prm PutPrm) error {
}
var shRes putToShardRes
e.iterateOverSortedShards(addr, func(_ int, sh hashedShard) (stop bool) {
if err := e.iterateOverSortedShards(ctx, addr, func(_ int, sh hashedShard) (stop bool) {
e.mtx.RLock()
_, ok := e.shards[sh.ID().String()]
e.mtx.RUnlock()
@ -106,7 +106,9 @@ func (e *StorageEngine) put(ctx context.Context, prm PutPrm) error {
}
shRes = e.putToShard(ctx, sh, addr, prm.Object, prm.IsIndexedContainer)
return shRes.status != putToShardUnknown
})
}); err != nil {
return err
}
switch shRes.status {
case putToShardUnknown:
return errPutShard