[#67] node: Accept expired locked objects

Allow replication of any (expired too) locked object. Information about
object locking is considered to be presented on the _container nodes_.

Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
Pavel Karpy 2023-03-15 04:07:27 +03:00
parent f006f3b342
commit 64bde68fb9
5 changed files with 75 additions and 3 deletions

View file

@ -27,6 +27,7 @@ type FormatValidatorOption func(*cfg)
type cfg struct {
netState netmap.State
e LockSource
}
// DeleteHandler is an interface of delete queue processor.
@ -38,6 +39,12 @@ type DeleteHandler interface {
DeleteObjects(oid.Address, ...oid.Address) error
}
// LockSource is a source of lock relations between the objects.
type LockSource interface {
// IsLocked must clarify object's lock status.
IsLocked(address oid.Address) (bool, error)
}
// Locker is an object lock storage interface.
type Locker interface {
// Lock list of objects as locked by locker in the specified container.
@ -319,7 +326,24 @@ func (v *FormatValidator) checkExpiration(obj *object.Object) error {
}
if exp < v.netState.CurrentEpoch() {
return errExpired
// an object could be expired but locked;
// put such an object is a correct operation
cID, _ := obj.ContainerID()
oID, _ := obj.ID()
var addr oid.Address
addr.SetContainer(cID)
addr.SetObject(oID)
locked, err := v.e.IsLocked(addr)
if err != nil {
return fmt.Errorf("locking status check for an expired object: %w", err)
}
if !locked {
return errExpired
}
}
return nil
@ -380,3 +404,10 @@ func WithNetState(netState netmap.State) FormatValidatorOption {
c.netState = netState
}
}
// WithLockSource return option to set the Storage Engine.
func WithLockSource(e LockSource) FormatValidatorOption {
return func(c *cfg) {
c.e = e
}
}