From da3c974c36cc6467d909264885f2d4f14b842d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 9 Feb 2023 13:31:42 +0200 Subject: [PATCH] ethdb/pebble: fix nil callbacks (#26650) --- ethdb/pebble/pebble.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ethdb/pebble/pebble.go b/ethdb/pebble/pebble.go index c850dc5a1..5ba7e03c2 100644 --- a/ethdb/pebble/pebble.go +++ b/ethdb/pebble/pebble.go @@ -117,7 +117,6 @@ func (d *Database) onWriteStallEnd() { // New returns a wrapped pebble DB object. The namespace is the prefix that the // metrics reporting should use for surfacing internal stats. func New(file string, cache int, handles int, namespace string, readonly bool) (*Database, error) { - var db *Database // Ensure we have some minimal caching and file guarantees if cache < minCache { cache = minCache @@ -140,6 +139,11 @@ func New(file string, cache int, handles int, namespace string, readonly bool) ( if memTableSize > maxMemTableSize { memTableSize = maxMemTableSize } + db := &Database{ + fn: file, + log: logger, + quitChan: make(chan chan error), + } opt := &pebble.Options{ // Pebble has a single combined cache area and the write // buffers are taken from this too. Assign all available @@ -187,13 +191,8 @@ func New(file string, cache int, handles int, namespace string, readonly bool) ( if err != nil { return nil, err } - // Assemble the wrapper with all the registered metrics - db = &Database{ - fn: file, - db: innerDB, - log: logger, - quitChan: make(chan chan error), - } + db.db = innerDB + db.compTimeMeter = metrics.NewRegisteredMeter(namespace+"compact/time", nil) db.compReadMeter = metrics.NewRegisteredMeter(namespace+"compact/input", nil) db.compWriteMeter = metrics.NewRegisteredMeter(namespace+"compact/output", nil)