[#734] writecache: Fix flush
Now UpdateStorageID doesn't return error in case of logical error. If object is in graveyard or GC market, it is still required to update storage ID. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
d5c10612f4
commit
7e0c5a55de
2 changed files with 25 additions and 1 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util/slice"
|
||||
|
@ -107,7 +108,9 @@ func (db *DB) UpdateStorageID(prm UpdateStorageIDPrm) (res UpdateStorageIDRes, e
|
|||
|
||||
err = db.boltDB.Batch(func(tx *bbolt.Tx) error {
|
||||
exists, err := db.exists(tx, prm.addr, currEpoch)
|
||||
if err == nil && exists || errors.Is(err, ErrObjectIsExpired) {
|
||||
if err == nil && exists {
|
||||
err = updateStorageID(tx, prm.addr, prm.id)
|
||||
} else if errors.As(err, new(logicerr.Logical)) {
|
||||
err = updateStorageID(tx, prm.addr, prm.id)
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ func TestDB_StorageID(t *testing.T) {
|
|||
|
||||
raw1 := testutil.GenerateObject()
|
||||
raw2 := testutil.GenerateObject()
|
||||
deleted := testutil.GenerateObject()
|
||||
|
||||
storageID := []byte{1, 2, 3, 4}
|
||||
|
||||
|
@ -34,6 +35,15 @@ func TestDB_StorageID(t *testing.T) {
|
|||
err = putBig(db, raw2)
|
||||
require.NoError(t, err)
|
||||
|
||||
// put object with storageID and delete it
|
||||
err = metaPut(db, deleted, storageID)
|
||||
require.NoError(t, err)
|
||||
|
||||
cnrID, ok := deleted.ContainerID()
|
||||
require.True(t, ok)
|
||||
ts := testutil.GenerateObjectWithCID(cnrID)
|
||||
require.NoError(t, metaInhume(db, object.AddressOf(deleted), object.AddressOf(ts)))
|
||||
|
||||
// check StorageID for object without storageID
|
||||
fetchedStorageID, err = metaStorageID(db, object.AddressOf(raw2))
|
||||
require.NoError(t, err)
|
||||
|
@ -44,12 +54,23 @@ func TestDB_StorageID(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.Equal(t, storageID, fetchedStorageID)
|
||||
|
||||
// check StorageID for deleted object with storageID
|
||||
fetchedStorageID, err = metaStorageID(db, object.AddressOf(deleted))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, storageID, fetchedStorageID)
|
||||
|
||||
t.Run("update", func(t *testing.T) {
|
||||
storageID := []byte{1, 2, 3, 4, 5}
|
||||
require.NoError(t, metaUpdateStorageID(db, object.AddressOf(raw2), storageID))
|
||||
require.NoError(t, metaUpdateStorageID(db, object.AddressOf(deleted), storageID))
|
||||
|
||||
fetchedStorageID, err = metaStorageID(db, object.AddressOf(raw2))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, storageID, fetchedStorageID)
|
||||
|
||||
fetchedStorageID, err = metaStorageID(db, object.AddressOf(deleted))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, storageID, fetchedStorageID)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue