diff --git a/pkg/local_object_storage/writecache/flush.go b/pkg/local_object_storage/writecache/flush.go index e995f0163e..9957fda05d 100644 --- a/pkg/local_object_storage/writecache/flush.go +++ b/pkg/local_object_storage/writecache/flush.go @@ -180,7 +180,7 @@ func (c *cache) flushFSTree(ignoreErrors bool) error { prm.Object = &obj prm.RawData = data - _, err = c.blobstor.Put(prm) + res, err := c.blobstor.Put(prm) if err != nil { if ignoreErrors { c.log.Error("cant flush object to blobstor", zap.Error(err)) @@ -189,6 +189,16 @@ func (c *cache) flushFSTree(ignoreErrors bool) error { return err } + var updPrm meta.UpdateStorageIDPrm + updPrm.SetAddress(addr) + updPrm.SetStorageID(res.StorageID) + + _, err = c.metabase.UpdateStorageID(updPrm) + if err != nil { + c.log.Error("failed to update storage ID in metabase", zap.Error(err)) + return nil + } + // mark object as flushed c.flushed.Add(sAddr, false) @@ -231,11 +241,11 @@ func (c *cache) flushObject(obj *object.Object) error { return err } - var pPrm meta.PutPrm - pPrm.SetObject(obj) - pPrm.SetStorageID(res.StorageID) + var updPrm meta.UpdateStorageIDPrm + updPrm.SetAddress(objectCore.AddressOf(obj)) + updPrm.SetStorageID(res.StorageID) - _, err = c.metabase.Put(pPrm) + _, err = c.metabase.UpdateStorageID(updPrm) return err } diff --git a/pkg/local_object_storage/writecache/options.go b/pkg/local_object_storage/writecache/options.go index ef38726fe4..76714f6d13 100644 --- a/pkg/local_object_storage/writecache/options.go +++ b/pkg/local_object_storage/writecache/options.go @@ -16,8 +16,8 @@ type Option func(*options) // meta is an interface for a metabase. type metabase interface { - Put(meta.PutPrm) (meta.PutRes, error) Exists(meta.ExistsPrm) (meta.ExistsRes, error) + UpdateStorageID(meta.UpdateStorageIDPrm) (meta.UpdateStorageIDRes, error) } // blob is an interface for the blobstor.