forked from TrueCloudLab/frostfs-node
[#585] writecache: Fix DB counter
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
58c8722c81
commit
2efe9cc1be
3 changed files with 31 additions and 5 deletions
|
@ -85,9 +85,15 @@ func (c *cache) putSmall(obj objectInfo) error {
|
|||
return ErrOutOfSpace
|
||||
}
|
||||
|
||||
var newRecord bool
|
||||
err := c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
b := tx.Bucket(defaultBucket)
|
||||
return b.Put([]byte(obj.addr), obj.data)
|
||||
key := []byte(obj.addr)
|
||||
newRecord = b.Get(key) == nil
|
||||
if newRecord {
|
||||
return b.Put(key, obj.data)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err == nil {
|
||||
storagelog.Write(c.log,
|
||||
|
@ -95,6 +101,10 @@ func (c *cache) putSmall(obj objectInfo) error {
|
|||
storagelog.StorageTypeField(wcStorageType),
|
||||
storagelog.OpField("db PUT"),
|
||||
)
|
||||
if newRecord {
|
||||
c.objCounters.cDB.Add(1)
|
||||
c.estimateCacheSize()
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -121,6 +131,7 @@ func (c *cache) putBig(ctx context.Context, addr string, prm common.PutPrm) erro
|
|||
storagelog.StorageTypeField(wcStorageType),
|
||||
storagelog.OpField("fstree PUT"),
|
||||
)
|
||||
c.estimateCacheSize()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue