[#2167] write-cache: Add "write-cache" to its logs

Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
Pavel Karpy 2022-12-20 15:29:05 +03:00 committed by Anton Nikiforov
parent eea2892109
commit 1608fd1c07
5 changed files with 44 additions and 8 deletions

View file

@ -36,14 +36,22 @@ func (c *cache) Delete(addr oid.Address) error {
if err != nil { if err != nil {
return err return err
} }
storagelog.Write(c.log, storagelog.AddressField(saddr), storagelog.OpField("db DELETE")) storagelog.Write(c.log,
storagelog.AddressField(saddr),
storagelog.StorageTypeField(wcStorageType),
storagelog.OpField("db DELETE"),
)
c.objCounters.DecDB() c.objCounters.DecDB()
return nil return nil
} }
_, err := c.fsTree.Delete(common.DeletePrm{Address: addr}) _, err := c.fsTree.Delete(common.DeletePrm{Address: addr})
if err == nil { if err == nil {
storagelog.Write(c.log, storagelog.AddressField(saddr), storagelog.OpField("fstree DELETE")) storagelog.Write(c.log,
storagelog.AddressField(saddr),
storagelog.StorageTypeField(wcStorageType),
storagelog.OpField("fstree DELETE"),
)
c.objCounters.DecFS() c.objCounters.DecFS()
} }

View file

@ -26,7 +26,11 @@ func (c *cache) initFlushMarks() {
_, err := c.fsTree.Delete(prm) _, err := c.fsTree.Delete(prm)
if err == nil { if err == nil {
storagelog.Write(c.log, storagelog.AddressField(addr), storagelog.OpField("fstree DELETE")) storagelog.Write(c.log,
storagelog.AddressField(addr),
storagelog.StorageTypeField(wcStorageType),
storagelog.OpField("fstree DELETE"),
)
} }
} }
} }
@ -83,7 +87,11 @@ func (c *cache) initFlushMarks() {
}) })
if err == nil { if err == nil {
for _, j := range indices { for _, j := range indices {
storagelog.Write(c.log, zap.String("address", m[j]), storagelog.OpField("db DELETE")) storagelog.Write(c.log,
zap.String("address", m[j]),
storagelog.StorageTypeField(wcStorageType),
storagelog.OpField("db DELETE"),
)
} }
} }
lastKey = append([]byte(m[len(m)-1]), 0) lastKey = append([]byte(m[len(m)-1]), 0)

View file

@ -53,7 +53,11 @@ func (c *cache) putSmall(obj objectInfo) error {
return b.Put([]byte(obj.addr), obj.data) return b.Put([]byte(obj.addr), obj.data)
}) })
if err == nil { if err == nil {
storagelog.Write(c.log, storagelog.AddressField(obj.addr), storagelog.OpField("db PUT")) storagelog.Write(c.log,
storagelog.AddressField(obj.addr),
storagelog.StorageTypeField(wcStorageType),
storagelog.OpField("db PUT"),
)
c.objCounters.IncDB() c.objCounters.IncDB()
} }
return nil return nil
@ -77,6 +81,11 @@ func (c *cache) putBig(addr string, prm common.PutPrm) error {
c.mtx.Unlock() c.mtx.Unlock()
} }
c.objCounters.IncFS() c.objCounters.IncFS()
storagelog.Write(c.log, storagelog.AddressField(addr), storagelog.OpField("fstree PUT")) storagelog.Write(c.log,
storagelog.AddressField(addr),
storagelog.StorageTypeField(wcStorageType),
storagelog.OpField("fstree PUT"),
)
return nil return nil
} }

View file

@ -109,7 +109,11 @@ func (c *cache) deleteFromDB(keys []string) []string {
}) })
for i := 0; i < errorIndex; i++ { for i := 0; i < errorIndex; i++ {
c.objCounters.DecDB() c.objCounters.DecDB()
storagelog.Write(c.log, storagelog.AddressField(keys[i]), storagelog.OpField("db DELETE")) storagelog.Write(c.log,
storagelog.AddressField(keys[i]),
storagelog.StorageTypeField(wcStorageType),
storagelog.OpField("db DELETE"),
)
} }
if err != nil { if err != nil {
c.log.Error("can't remove objects from the database", zap.Error(err)) c.log.Error("can't remove objects from the database", zap.Error(err))
@ -142,7 +146,11 @@ func (c *cache) deleteFromDisk(keys []string) []string {
copyIndex++ copyIndex++
continue continue
} else if err == nil { } else if err == nil {
storagelog.Write(c.log, storagelog.AddressField(keys[i]), storagelog.OpField("fstree DELETE")) storagelog.Write(c.log,
storagelog.AddressField(keys[i]),
storagelog.StorageTypeField(wcStorageType),
storagelog.OpField("fstree DELETE"),
)
c.objCounters.DecFS() c.objCounters.DecFS()
} }
} }

View file

@ -67,6 +67,9 @@ type cache struct {
fsTree *fstree.FSTree fsTree *fstree.FSTree
} }
// wcStorageType is used for write-cache operations logging.
const wcStorageType = "write-cache"
type objectInfo struct { type objectInfo struct {
addr string addr string
data []byte data []byte