Skip to content

Commit

Permalink
[nspcc-dev#1461] engine, policer: Force remove objects w/o container
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
  • Loading branch information
carpawell authored and aprasolova committed Oct 19, 2022
1 parent fda4525 commit 875d326
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/local_object_storage/engine/inhume.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
type InhumePrm struct {
tombstone *oid.Address
addrs []oid.Address

forceRemoval bool
}

// InhumeRes encapsulates results of inhume operation.
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions pkg/services/policer/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 875d326

Please sign in to comment.