forked from TrueCloudLab/frostfs-node
[#1175] storage engine: Fix Lock
implementation
`Lock` must return `apistatus.IrregularObjectLock` error instead of `apistatus.ObjectLocked` one. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
07107c8bfd
commit
d163008b63
1 changed files with 6 additions and 6 deletions
|
@ -32,11 +32,11 @@ func (e *StorageEngine) lock(idCnr cid.ID, locker oid.ID, locked []oid.ID) error
|
||||||
for i := range locked {
|
for i := range locked {
|
||||||
switch e.lockSingle(idCnr, locker, locked[i], true) {
|
switch e.lockSingle(idCnr, locker, locked[i], true) {
|
||||||
case 1:
|
case 1:
|
||||||
return apistatus.ObjectLocked{}
|
return apistatus.IrregularObjectLock{}
|
||||||
case 0:
|
case 0:
|
||||||
switch e.lockSingle(idCnr, locker, locked[i], true) {
|
switch e.lockSingle(idCnr, locker, locked[i], false) {
|
||||||
case 1:
|
case 1:
|
||||||
return apistatus.ObjectLocked{}
|
return apistatus.IrregularObjectLock{}
|
||||||
case 0:
|
case 0:
|
||||||
return errLockFailed
|
return errLockFailed
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ func (e *StorageEngine) lock(idCnr cid.ID, locker oid.ID, locked []oid.ID) error
|
||||||
|
|
||||||
// Returns:
|
// Returns:
|
||||||
// 0 - fail
|
// 0 - fail
|
||||||
// 1 - object locked
|
// 1 - locking irregular object
|
||||||
// 2 - ok
|
// 2 - ok
|
||||||
func (e *StorageEngine) lockSingle(idCnr cid.ID, locker, locked oid.ID, checkExists bool) (status uint8) {
|
func (e *StorageEngine) lockSingle(idCnr cid.ID, locker, locked oid.ID, checkExists bool) (status uint8) {
|
||||||
// code is pretty similar to inhumeAddr, maybe unify?
|
// code is pretty similar to inhumeAddr, maybe unify?
|
||||||
root := false
|
root := false
|
||||||
var errLocked apistatus.ObjectLocked
|
var errIrregular apistatus.IrregularObjectLock
|
||||||
|
|
||||||
var addrLocked address.Address
|
var addrLocked address.Address
|
||||||
addrLocked.SetContainerID(&idCnr)
|
addrLocked.SetContainerID(&idCnr)
|
||||||
|
@ -89,7 +89,7 @@ func (e *StorageEngine) lockSingle(idCnr cid.ID, locker, locked oid.ID, checkExi
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.reportShardError(sh, "could not lock object in shard", err)
|
e.reportShardError(sh, "could not lock object in shard", err)
|
||||||
|
|
||||||
if errors.As(err, &errLocked) {
|
if errors.As(err, &errIrregular) {
|
||||||
status = 1
|
status = 1
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue