forked from TrueCloudLab/frostfs-node
[#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:
parent
a27e003508
commit
3a441f072f
12 changed files with 149 additions and 86 deletions
|
@ -71,7 +71,7 @@ func (e *StorageEngine) delete(ctx context.Context, prm DeletePrm) error {
|
|||
// Removal of a big object is done in multiple stages:
|
||||
// 1. Remove the parent object. If it is locked or already removed, return immediately.
|
||||
// 2. Otherwise, search for all objects with a particular SplitID and delete them too.
|
||||
e.iterateOverSortedShards(prm.addr, func(_ int, sh hashedShard) (stop bool) {
|
||||
if err := e.iterateOverSortedShards(ctx, prm.addr, func(_ int, sh hashedShard) (stop bool) {
|
||||
var existsPrm shard.ExistsPrm
|
||||
existsPrm.Address = prm.addr
|
||||
|
||||
|
@ -116,20 +116,22 @@ func (e *StorageEngine) delete(ctx context.Context, prm DeletePrm) error {
|
|||
|
||||
// If a parent object is removed we should set GC mark on each shard.
|
||||
return splitInfo == nil
|
||||
})
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if locked.is {
|
||||
return new(apistatus.ObjectLocked)
|
||||
}
|
||||
|
||||
if splitInfo != nil {
|
||||
e.deleteChildren(ctx, prm.addr, prm.forceRemoval, splitInfo.SplitID())
|
||||
return e.deleteChildren(ctx, prm.addr, prm.forceRemoval, splitInfo.SplitID())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *StorageEngine) deleteChildren(ctx context.Context, addr oid.Address, force bool, splitID *objectSDK.SplitID) {
|
||||
func (e *StorageEngine) deleteChildren(ctx context.Context, addr oid.Address, force bool, splitID *objectSDK.SplitID) error {
|
||||
var fs objectSDK.SearchFilters
|
||||
fs.AddSplitIDFilter(objectSDK.MatchStringEqual, splitID)
|
||||
|
||||
|
@ -142,7 +144,7 @@ func (e *StorageEngine) deleteChildren(ctx context.Context, addr oid.Address, fo
|
|||
inhumePrm.ForceRemoval()
|
||||
}
|
||||
|
||||
e.iterateOverSortedShards(addr, func(_ int, sh hashedShard) (stop bool) {
|
||||
return e.iterateOverSortedShards(ctx, addr, func(_ int, sh hashedShard) (stop bool) {
|
||||
res, err := sh.Select(ctx, selectPrm)
|
||||
if err != nil {
|
||||
e.log.Warn(ctx, logs.EngineErrorDuringSearchingForObjectChildren,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue