From 14ea7b2c473a7be1f249225fad9f789cbd32971f Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Sat, 5 Mar 2022 13:43:13 +0300 Subject: [PATCH] [#1219] object/delete: Change approach of the tombstone broadcast After `putsvc.Service` started to support additional container broadcast of the saved objects there is no more need to perform broadcast of tombstone object in `deletesvc.Service`. Make `putsvc.Service` to perform additional broadcast of `TOMBSTONE` objects. Remove `broadcastTombstone` stage from `deletesvc.execCtx`, from now it is encapsulated in `saveTombstone` stage. Remove no longer needed `putsvc.PutInitPrm.WithTraverseOption` method. Signed-off-by: Leonard Lyubich --- pkg/services/object/delete/exec.go | 21 +-------------------- pkg/services/object/delete/local.go | 9 +-------- pkg/services/object/delete/service.go | 2 +- pkg/services/object/delete/util.go | 7 +------ pkg/services/object/put/prm.go | 8 -------- pkg/services/object/put/streamer.go | 7 +++++++ 6 files changed, 11 insertions(+), 43 deletions(-) diff --git a/pkg/services/object/delete/exec.go b/pkg/services/object/delete/exec.go index 64de62b4d..e712bb876 100644 --- a/pkg/services/object/delete/exec.go +++ b/pkg/services/object/delete/exec.go @@ -255,7 +255,7 @@ func (exec *execCtx) initTombstoneObject() bool { } func (exec *execCtx) saveTombstone() bool { - id, err := exec.svc.placer.put(exec, false) + id, err := exec.svc.placer.put(exec) switch { default: @@ -277,22 +277,3 @@ func (exec *execCtx) saveTombstone() bool { return true } - -func (exec *execCtx) broadcastTombstone() bool { - _, err := exec.svc.placer.put(exec, true) - - switch { - default: - exec.status = statusUndefined - exec.err = err - - exec.log.Debug("could not save the tombstone", - zap.String("error", err.Error()), - ) - case err == nil: - exec.status = statusOK - exec.err = nil - } - - return err == nil -} diff --git a/pkg/services/object/delete/local.go b/pkg/services/object/delete/local.go index a696e95d5..7ec59456d 100644 --- a/pkg/services/object/delete/local.go +++ b/pkg/services/object/delete/local.go @@ -16,14 +16,7 @@ func (exec *execCtx) executeLocal() { exec.log.Debug("tombstone structure successfully formed, saving...") - ok = exec.saveTombstone() - if !ok { - return - } - - exec.log.Debug("tombstone successfilly saved, broadcasting...") - - exec.broadcastTombstone() + exec.saveTombstone() } func (exec *execCtx) formTombstone() (ok bool) { diff --git a/pkg/services/object/delete/service.go b/pkg/services/object/delete/service.go index 7846344b5..ef0e2c1e6 100644 --- a/pkg/services/object/delete/service.go +++ b/pkg/services/object/delete/service.go @@ -51,7 +51,7 @@ type cfg struct { } placer interface { - put(*execCtx, bool) (*oidSDK.ID, error) + put(*execCtx) (*oidSDK.ID, error) } netInfo NetworkInfo diff --git a/pkg/services/object/delete/util.go b/pkg/services/object/delete/util.go index 852a27264..a8944d0a4 100644 --- a/pkg/services/object/delete/util.go +++ b/pkg/services/object/delete/util.go @@ -6,7 +6,6 @@ import ( getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get" putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put" searchsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/search" - "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-sdk-go/object" addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address" oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id" @@ -102,7 +101,7 @@ func (s *simpleIDWriter) WriteIDs(ids []*oidSDK.ID) error { return nil } -func (w *putSvcWrapper) put(exec *execCtx, broadcast bool) (*oidSDK.ID, error) { +func (w *putSvcWrapper) put(exec *execCtx) (*oidSDK.ID, error) { streamer, err := (*putsvc.Service)(w).Put(exec.context()) if err != nil { return nil, err @@ -114,10 +113,6 @@ func (w *putSvcWrapper) put(exec *execCtx, broadcast bool) (*oidSDK.ID, error) { WithCommonPrm(exec.commonParameters()). WithObject(exec.tombstoneObj.CutPayload()) - if broadcast { - initPrm.WithTraverseOption(placement.WithoutSuccessTracking()) - } - err = streamer.Init(initPrm) if err != nil { return nil, err diff --git a/pkg/services/object/put/prm.go b/pkg/services/object/put/prm.go index e3bc7ed7c..19ea0fc92 100644 --- a/pkg/services/object/put/prm.go +++ b/pkg/services/object/put/prm.go @@ -29,14 +29,6 @@ func (p *PutInitPrm) WithCommonPrm(v *util.CommonPrm) *PutInitPrm { return p } -func (p *PutInitPrm) WithTraverseOption(opt placement.Option) *PutInitPrm { - if p != nil { - p.traverseOpts = append(p.traverseOpts, opt) - } - - return p -} - func (p *PutInitPrm) WithObject(v *object.Object) *PutInitPrm { if p != nil { p.hdr = v diff --git a/pkg/services/object/put/streamer.go b/pkg/services/object/put/streamer.go index 50bbb02df..41ca72322 100644 --- a/pkg/services/object/put/streamer.go +++ b/pkg/services/object/put/streamer.go @@ -10,6 +10,7 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/services/object/util" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/transformer" + "github.com/nspcc-dev/neofs-sdk-go/object" ) type Streamer struct { @@ -160,9 +161,15 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget { } } + // enable additional container broadcast on non-local operation + // if object has TOMBSTONE type. + withBroadcast := !prm.common.LocalOnly() && prm.hdr.Type() == object.TypeTombstone + return &distributedTarget{ traversal: traversal{ opts: prm.traverseOpts, + + extraBroadcastEnabled: withBroadcast, }, remotePool: p.remotePool, localPool: p.localPool,