forked from TrueCloudLab/frostfs-node
[#1181] local storage: Process expired locks similar to tombstones
There is a need to process expired `LOCK` objects similar to `TOMBSTONE` ones: we collect them on `Shard`, notify all other shards about expiration so they could unlock the objects, and only after that mark lockers as garbage. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
ebd84f6dd4
commit
9dff07200c
9 changed files with 369 additions and 29 deletions
|
@ -3,10 +3,12 @@ package meta_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
objectcore "github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
|
||||
objecttest "github.com/nspcc-dev/neofs-sdk-go/object/test"
|
||||
|
@ -48,4 +50,37 @@ func TestDB_Lock(t *testing.T) {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("lock-unlock scenario", func(t *testing.T) {
|
||||
cnr := cidtest.ID()
|
||||
|
||||
obj := generateObjectWithCID(t, cnr)
|
||||
|
||||
var err error
|
||||
|
||||
err = putBig(db, obj)
|
||||
require.NoError(t, err)
|
||||
|
||||
tombID := *oidtest.ID()
|
||||
|
||||
// lock the object
|
||||
err = db.Lock(*cnr, tombID, []oid.ID{*obj.ID()})
|
||||
require.NoError(t, err)
|
||||
|
||||
var tombAddr address.Address
|
||||
tombAddr.SetContainerID(cnr)
|
||||
tombAddr.SetObjectID(&tombID)
|
||||
|
||||
// try to inhume locked object using tombstone
|
||||
err = meta.Inhume(db, objectcore.AddressOf(obj), &tombAddr)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
|
||||
// inhume the tombstone
|
||||
_, err = db.Inhume(new(meta.InhumePrm).WithAddresses(&tombAddr).WithGCMark())
|
||||
require.NoError(t, err)
|
||||
|
||||
// now we can inhume the object
|
||||
err = meta.Inhume(db, objectcore.AddressOf(obj), &tombAddr)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue