From ce169491edd3fdf8ca9db40a67acac6528feddbe Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 2 Mar 2022 12:17:32 +0300 Subject: [PATCH] [#1188] metabase: log PUT / DELETE operations Signed-off-by: Evgenii Stratonikov (cherry picked from commit 6e6f3648d262e09241d9b163a8823fad07368a8e) --- pkg/local_object_storage/metabase/delete.go | 11 ++++++++++- pkg/local_object_storage/metabase/put.go | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/metabase/delete.go b/pkg/local_object_storage/metabase/delete.go index cd62f043..89b02648 100644 --- a/pkg/local_object_storage/metabase/delete.go +++ b/pkg/local_object_storage/metabase/delete.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/nspcc-dev/neofs-node/pkg/core/object" + storagelog "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/log" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" "go.etcd.io/bbolt" ) @@ -47,9 +48,17 @@ type referenceCounter map[string]*referenceNumber // Delete removed object records from metabase indexes. func (db *DB) Delete(prm *DeletePrm) (*DeleteRes, error) { - return new(DeleteRes), db.boltDB.Update(func(tx *bbolt.Tx) error { + err := db.boltDB.Update(func(tx *bbolt.Tx) error { return db.deleteGroup(tx, prm.addrs) }) + if err == nil { + for i := range prm.addrs { + storagelog.Write(db.log, + storagelog.AddressField(prm.addrs[i]), + storagelog.OpField("metabase DELETE")) + } + } + return new(DeleteRes), err } func (db *DB) deleteGroup(tx *bbolt.Tx, addrs []*objectSDK.Address) error { diff --git a/pkg/local_object_storage/metabase/put.go b/pkg/local_object_storage/metabase/put.go index fb9df189..e3482751 100644 --- a/pkg/local_object_storage/metabase/put.go +++ b/pkg/local_object_storage/metabase/put.go @@ -7,6 +7,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza" + storagelog "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/log" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" "go.etcd.io/bbolt" @@ -68,6 +69,11 @@ func (db *DB) Put(prm *PutPrm) (res *PutRes, err error) { err = db.boltDB.Batch(func(tx *bbolt.Tx) error { return db.put(tx, prm.obj, prm.id, nil) }) + if err == nil { + storagelog.Write(db.log, + storagelog.AddressField(prm.obj.Address()), + storagelog.OpField("metabase PUT")) + } return }