From db1e95cf5fa5bbced5e409f433413a62a81523a4 Mon Sep 17 00:00:00 2001 From: Bill Katz Date: Wed, 1 May 2024 11:14:07 -0400 Subject: [PATCH] fix delete instance debug messages --- storage/badger/badger.go | 7 +++++-- storage/basholeveldb/basholeveldb.go | 14 ++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/storage/badger/badger.go b/storage/badger/badger.go index 5b8b4ba6..23b892cf 100644 --- a/storage/badger/badger.go +++ b/storage/badger/badger.go @@ -1019,6 +1019,7 @@ func (db *BadgerDB) DeleteAll(ctx storage.Context) error { var err error var minKey, maxKey storage.Key + var name string vctx, versioned := ctx.(storage.VersionedCtx) if versioned { // Don't have to worry about tombstones. Delete all keys from all versions for this instance id. @@ -1032,8 +1033,10 @@ func (db *BadgerDB) DeleteAll(ctx storage.Context) error { if err != nil { return err } + name = vctx.Data().DataName() } else { minKey, maxKey = ctx.KeyRange() + name = ctx.String() } const BATCH_SIZE = 10000 @@ -1062,7 +1065,7 @@ func (db *BadgerDB) DeleteAll(ctx storage.Context) error { return fmt.Errorf("Error on flush of DeleteAll at key-value pair %d: %v", numKV, err) } wb = db.bdp.NewWriteBatch() - dvid.Debugf("Deleted %d key-value pairs in ongoing DELETE ALL for %s.\n", numKV+1, vctx) + dvid.Debugf("Deleted %d key-value pairs in ongoing DELETE ALL for %s.\n", numKV+1, name) } numKV++ } @@ -1078,7 +1081,7 @@ func (db *BadgerDB) DeleteAll(ctx storage.Context) error { return err } - dvid.Debugf("Deleted %d key-value pairs via DELETE ALL for %s.\n", numKV, vctx) + dvid.Debugf("Deleted %d key-value pairs via DELETE ALL for %s.\n", numKV, name) return nil } diff --git a/storage/basholeveldb/basholeveldb.go b/storage/basholeveldb/basholeveldb.go index 5ab46ab2..f0e57d04 100644 --- a/storage/basholeveldb/basholeveldb.go +++ b/storage/basholeveldb/basholeveldb.go @@ -21,9 +21,12 @@ import ( ) // These constants were guided by Basho documentation and their tuning of leveldb: -// https://github.com/basho/leveldb/blob/develop/README +// +// https://github.com/basho/leveldb/blob/develop/README +// // See video on "Optimizing LevelDB for Performance and Scale" here: -// http://www.youtube.com/watch?v=vo88IdglU_8 +// +// http://www.youtube.com/watch?v=vo88IdglU_8 const ( // Default size of LRU cache that caches frequently used uncompressed blocks. DefaultCacheSize = 536870912 @@ -1118,6 +1121,7 @@ func (db *LevelDB) DeleteAll(ctx storage.Context) error { var err error var minKey, maxKey storage.Key + var name string vctx, versioned := ctx.(storage.VersionedCtx) if versioned { @@ -1132,8 +1136,10 @@ func (db *LevelDB) DeleteAll(ctx storage.Context) error { if err != nil { return err } + name = string(vctx.Data().DataName()) } else { minKey, maxKey = ctx.KeyRange() + name = ctx.String() } const BATCH_SIZE = 10000 @@ -1167,7 +1173,7 @@ func (db *LevelDB) DeleteAll(ctx storage.Context) error { return fmt.Errorf("Error on batch commit of DeleteAll at key-value pair %d: %v", numKV, err) } batch = db.NewBatch(ctx).(*goBatch) - dvid.Debugf("Deleted %d key-value pairs in ongoing DELETE ALL for %s.\n", numKV+1, ctx) + dvid.Debugf("Deleted %d key-value pairs in ongoing DELETE ALL for %s.\n", numKV+1, name) } numKV++ it.Next() @@ -1181,7 +1187,7 @@ func (db *LevelDB) DeleteAll(ctx storage.Context) error { return fmt.Errorf("Error on last batch commit of DeleteAll: %v", err) } } - dvid.Debugf("Deleted %d key-value pairs via DELETE ALL for %s.\n", numKV, ctx) + dvid.Debugf("Deleted %d key-value pairs via DELETE ALL for %s.\n", numKV, name) return nil }