forked from TrueCloudLab/frostfs-node
[#790] writecache: Log each writing operation
Call `storagelog.Write` in all places after the successful writing op. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
4f73c00776
commit
3258d9c616
5 changed files with 27 additions and 1 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
|
||||||
|
storagelog "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/log"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ func (c *cache) Delete(addr *objectSDK.Address) error {
|
||||||
c.mem = c.mem[:len(c.mem)-1]
|
c.mem = c.mem[:len(c.mem)-1]
|
||||||
c.curMemSize -= uint64(len(c.mem[i].data))
|
c.curMemSize -= uint64(len(c.mem[i].data))
|
||||||
c.mtx.Unlock()
|
c.mtx.Unlock()
|
||||||
|
storagelog.Write(c.log, storagelog.AddressField(saddr), storagelog.OpField("in-mem DELETE"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +46,7 @@ func (c *cache) Delete(addr *objectSDK.Address) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c.dbSize.Sub(uint64(has))
|
c.dbSize.Sub(uint64(has))
|
||||||
|
storagelog.Write(c.log, storagelog.AddressField(saddr), storagelog.OpField("db DELETE"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,5 +55,9 @@ func (c *cache) Delete(addr *objectSDK.Address) error {
|
||||||
err = object.ErrNotFound
|
err = object.ErrNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
storagelog.Write(c.log, storagelog.AddressField(saddr), storagelog.OpField("fstree DELETE"))
|
||||||
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ type options struct {
|
||||||
// WithLogger sets logger.
|
// WithLogger sets logger.
|
||||||
func WithLogger(log *zap.Logger) Option {
|
func WithLogger(log *zap.Logger) Option {
|
||||||
return func(o *options) {
|
return func(o *options) {
|
||||||
o.log = log
|
o.log = log.With(zap.String("component", "WriteCache"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
storagelog "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/log"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -30,6 +31,13 @@ func (c *cache) persistLoop() {
|
||||||
zap.Duration("took", time.Since(start)),
|
zap.Duration("took", time.Since(start)),
|
||||||
zap.Int("total", len(m)))
|
zap.Int("total", len(m)))
|
||||||
|
|
||||||
|
for i := range m {
|
||||||
|
storagelog.Write(c.log,
|
||||||
|
storagelog.AddressField(m[i].addr),
|
||||||
|
storagelog.OpField("in-mem DELETE persist"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
c.mtx.Lock()
|
c.mtx.Lock()
|
||||||
c.curMemSize = 0
|
c.curMemSize = 0
|
||||||
n := copy(c.mem, c.mem[len(m):])
|
n := copy(c.mem, c.mem[len(m):])
|
||||||
|
@ -64,6 +72,7 @@ func (c *cache) persistToCache(objs []objectInfo) []int {
|
||||||
}
|
}
|
||||||
sz += uint64(len(objs[i].data))
|
sz += uint64(len(objs[i].data))
|
||||||
doneMem = append(doneMem, i)
|
doneMem = append(doneMem, i)
|
||||||
|
storagelog.Write(c.log, storagelog.AddressField(objs[i].addr), storagelog.OpField("db PUT"))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@ -88,6 +97,8 @@ func (c *cache) persistToCache(objs []objectInfo) []int {
|
||||||
err := c.fsTree.Put(objs[i].obj.Address(), objs[i].data)
|
err := c.fsTree.Put(objs[i].obj.Address(), objs[i].data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failDisk = append(failDisk, i)
|
failDisk = append(failDisk, i)
|
||||||
|
} else {
|
||||||
|
storagelog.Write(c.log, storagelog.AddressField(objs[i].addr), storagelog.OpField("fstree PUT"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
|
storagelog "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrBigObject is returned when object is too big to be placed in cache.
|
// ErrBigObject is returned when object is too big to be placed in cache.
|
||||||
|
@ -34,6 +35,9 @@ func (c *cache) Put(o *object.Object) error {
|
||||||
c.mem = append(c.mem, oi)
|
c.mem = append(c.mem, oi)
|
||||||
|
|
||||||
c.mtx.Unlock()
|
c.mtx.Unlock()
|
||||||
|
|
||||||
|
storagelog.Write(c.log, storagelog.AddressField(oi.addr), storagelog.OpField("in-mem PUT"))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
|
||||||
|
storagelog "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/log"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util"
|
"github.com/nspcc-dev/neofs-node/pkg/util"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -109,6 +110,7 @@ func (c *cache) deleteFromDB(keys [][]byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sz += uint64(len(has))
|
sz += uint64(len(has))
|
||||||
|
storagelog.Write(c.log, storagelog.AddressField(string(keys[i])), storagelog.OpField("db DELETE"))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@ -135,6 +137,8 @@ func (c *cache) deleteFromDisk(keys [][]byte) error {
|
||||||
lastErr = err
|
lastErr = err
|
||||||
c.log.Error("can't remove object from write-cache", zap.Error(err))
|
c.log.Error("can't remove object from write-cache", zap.Error(err))
|
||||||
continue
|
continue
|
||||||
|
} else if err == nil {
|
||||||
|
storagelog.Write(c.log, storagelog.AddressField(string(keys[i])), storagelog.OpField("fstree DELETE"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue