forked from TrueCloudLab/frostfs-node
[#1818] writecache: Update storage ID during flush
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
5cf75404dc
commit
bffb0f894c
2 changed files with 16 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue