From 51afcc1182eb07c0cf99bca0d1567fc44bad18e8 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Tue, 14 Jun 2022 20:48:33 +0300 Subject: [PATCH] [#1461] engine, policer: Force remove objects w/o container Signed-off-by: Pavel Karpy --- pkg/local_object_storage/engine/inhume.go | 14 ++++++++++++++ pkg/services/policer/check.go | 2 ++ 2 files changed, 16 insertions(+) diff --git a/pkg/local_object_storage/engine/inhume.go b/pkg/local_object_storage/engine/inhume.go index 3323a6f9f..20ec7ec7d 100644 --- a/pkg/local_object_storage/engine/inhume.go +++ b/pkg/local_object_storage/engine/inhume.go @@ -15,6 +15,8 @@ import ( type InhumePrm struct { tombstone *oid.Address addrs []oid.Address + + forceRemoval bool } // InhumeRes encapsulates results of inhume operation. @@ -42,6 +44,15 @@ func (p *InhumePrm) MarkAsGarbage(addrs ...oid.Address) { } } +// WithForceRemoval inhumes objects specified via MarkAsGarbage with GC mark +// without any object restrictions checks. +func (p *InhumePrm) WithForceRemoval() { + if p != nil { + p.forceRemoval = true + p.tombstone = nil + } +} + var errInhumeFailure = errors.New("inhume operation failed") // Inhume calls metabase. Inhume method to mark an object as removed. It won't be @@ -66,6 +77,9 @@ func (e *StorageEngine) inhume(prm InhumePrm) (InhumeRes, error) { } var shPrm shard.InhumePrm + if prm.forceRemoval { + shPrm.ForceRemoval() + } for i := range prm.addrs { if prm.tombstone != nil { diff --git a/pkg/services/policer/check.go b/pkg/services/policer/check.go index e2a670dc7..5de6d5cba 100644 --- a/pkg/services/policer/check.go +++ b/pkg/services/policer/check.go @@ -31,6 +31,8 @@ func (p *Policer) processObject(ctx context.Context, addr oid.Address) { if container.IsErrNotFound(err) { var prm engine.InhumePrm prm.MarkAsGarbage(addr) + prm.WithForceRemoval() + _, err := p.jobQueue.localStorage.Inhume(prm) if err != nil { p.log.Error("could not inhume object with missing container",