From 6e6f3648d262e09241d9b163a8823fad07368a8e 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 --- 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 3093ab9b..a0c8b398 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" addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address" "go.etcd.io/bbolt" @@ -48,9 +49,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 []*addressSDK.Address) error { diff --git a/pkg/local_object_storage/metabase/put.go b/pkg/local_object_storage/metabase/put.go index 7d965fe0..14a366c1 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" addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address" @@ -69,6 +70,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 }