[#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:
Leonard Lyubich 2022-03-10 20:58:58 +03:00 committed by LeL
parent ebd84f6dd4
commit 9dff07200c
9 changed files with 369 additions and 29 deletions

View file

@ -6,13 +6,11 @@ import (
"math/rand"
"os"
"path/filepath"
"sync"
"testing"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/util/test"
"github.com/nspcc-dev/neofs-sdk-go/checksum"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
@ -74,14 +72,7 @@ func benchmarkExists(b *testing.B, shardNum int) {
}
func testNewEngineWithShards(shards ...*shard.Shard) *StorageEngine {
engine := &StorageEngine{
cfg: &cfg{
log: zap.L(),
},
mtx: new(sync.RWMutex),
shards: make(map[string]shardWrapper, len(shards)),
shardPools: make(map[string]util.WorkerPool, len(shards)),
}
engine := New()
for _, s := range shards {
pool, err := ants.NewPool(10, ants.WithNonblocking(true))
@ -123,6 +114,32 @@ func testNewShard(t testing.TB, id int) *shard.Shard {
return s
}
func testEngineFromShardOpts(t *testing.T, num int, extraOpts func(int) []shard.Option) *StorageEngine {
engine := New()
for i := 0; i < num; i++ {
sid, err := generateShardID()
require.NoError(t, err)
err = engine.addShard(sid, append([]shard.Option{
shard.WithBlobStorOptions(
blobstor.WithRootPath(filepath.Join(t.Name(), fmt.Sprintf("%d.blobstor", sid))),
blobstor.WithBlobovniczaShallowWidth(1),
blobstor.WithBlobovniczaShallowDepth(1),
blobstor.WithRootPerm(0700),
),
shard.WithMetaBaseOptions(
meta.WithPath(filepath.Join(t.Name(), fmt.Sprintf("%d.metabase", sid))),
meta.WithPermissions(0700),
)}, extraOpts(i)...)...)
require.NoError(t, err)
}
require.NoError(t, engine.Open())
require.NoError(t, engine.Init())
return engine
}
func testOID() *oidSDK.ID {
cs := [sha256.Size]byte{}
_, _ = rand.Read(cs[:])