forked from TrueCloudLab/frostfs-node
[#1972] node: Do not save objects if node not in a container
Do not use node's local storage if it is clear that an object will be removed anyway as a redundant. It requires moving the changing local storage logic from the validation step to the local target implementation. It allows performing any relations checks (e.g. object locking) only if a node is considered as a valid container member and is expected to store (stored previously) all the helper objects (e.g. `LOCK`, `TOMBSTONE`, etc). Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
a77392e9ce
commit
aab398f4f5
7 changed files with 158 additions and 117 deletions
|
@ -97,20 +97,6 @@ func (s *objectSvc) GetRangeHash(ctx context.Context, req *object.GetRangeHashRe
|
|||
return s.get.GetRangeHash(ctx, req)
|
||||
}
|
||||
|
||||
type localObjectInhumer struct {
|
||||
storage *engine.StorageEngine
|
||||
|
||||
log *logger.Logger
|
||||
}
|
||||
|
||||
func (r *localObjectInhumer) DeleteObjects(ts oid.Address, addr ...oid.Address) error {
|
||||
var prm engine.InhumePrm
|
||||
prm.WithTarget(ts, addr...)
|
||||
|
||||
_, err := r.storage.Inhume(prm)
|
||||
return err
|
||||
}
|
||||
|
||||
type delNetInfo struct {
|
||||
netmap.State
|
||||
tsLifetime uint64
|
||||
|
@ -202,11 +188,6 @@ func initObjectService(c *cfg) {
|
|||
}
|
||||
}
|
||||
|
||||
objInhumer := &localObjectInhumer{
|
||||
storage: ls,
|
||||
log: c.log,
|
||||
}
|
||||
|
||||
c.replicator = replicator.New(
|
||||
replicator.WithLogger(c.log),
|
||||
replicator.WithPutTimeout(
|
||||
|
@ -254,7 +235,7 @@ func initObjectService(c *cfg) {
|
|||
c.workers = append(c.workers, pol)
|
||||
|
||||
var os putsvc.ObjectStorage = engineWithoutNotifications{
|
||||
e: ls,
|
||||
engine: ls,
|
||||
}
|
||||
|
||||
if c.cfgNotifications.enabled {
|
||||
|
@ -274,10 +255,6 @@ func initObjectService(c *cfg) {
|
|||
putsvc.WithContainerSource(c.cfgObject.cnrSource),
|
||||
putsvc.WithNetworkMapSource(c.netMapSource),
|
||||
putsvc.WithNetmapKeys(c),
|
||||
putsvc.WithFormatValidatorOpts(
|
||||
objectCore.WithDeleteHandler(objInhumer),
|
||||
objectCore.WithLocker(ls),
|
||||
),
|
||||
putsvc.WithNetworkState(c.cfgNetmap.state),
|
||||
putsvc.WithWorkerPools(c.cfgObject.pool.putRemote),
|
||||
putsvc.WithLogger(c.log),
|
||||
|
@ -561,6 +538,14 @@ type engineWithNotifications struct {
|
|||
defaultTopic string
|
||||
}
|
||||
|
||||
func (e engineWithNotifications) Delete(tombstone oid.Address, toDelete []oid.ID) error {
|
||||
return e.base.Delete(tombstone, toDelete)
|
||||
}
|
||||
|
||||
func (e engineWithNotifications) Lock(locker oid.Address, toLock []oid.ID) error {
|
||||
return e.base.Lock(locker, toLock)
|
||||
}
|
||||
|
||||
func (e engineWithNotifications) Put(o *objectSDK.Object) error {
|
||||
if err := e.base.Put(o); err != nil {
|
||||
return err
|
||||
|
@ -583,9 +568,28 @@ func (e engineWithNotifications) Put(o *objectSDK.Object) error {
|
|||
}
|
||||
|
||||
type engineWithoutNotifications struct {
|
||||
e *engine.StorageEngine
|
||||
engine *engine.StorageEngine
|
||||
}
|
||||
|
||||
func (e engineWithoutNotifications) Delete(tombstone oid.Address, toDelete []oid.ID) error {
|
||||
var prm engine.InhumePrm
|
||||
|
||||
addrs := make([]oid.Address, len(toDelete))
|
||||
for i := range addrs {
|
||||
addrs[i].SetContainer(tombstone.Container())
|
||||
addrs[i].SetObject(toDelete[i])
|
||||
}
|
||||
|
||||
prm.WithTarget(tombstone, addrs...)
|
||||
|
||||
_, err := e.engine.Inhume(prm)
|
||||
return err
|
||||
}
|
||||
|
||||
func (e engineWithoutNotifications) Lock(locker oid.Address, toLock []oid.ID) error {
|
||||
return e.engine.Lock(locker.Container(), locker.Object(), toLock)
|
||||
}
|
||||
|
||||
func (e engineWithoutNotifications) Put(o *objectSDK.Object) error {
|
||||
return engine.Put(e.e, o)
|
||||
return engine.Put(e.engine, o)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue