@@ -117,7 +117,6 @@ func (d *Database) onWriteStallEnd() {
117117// New returns a wrapped pebble DB object. The namespace is the prefix that the
118118// metrics reporting should use for surfacing internal stats.
119119func New (file string , cache int , handles int , namespace string , readonly bool ) (* Database , error ) {
120- var db * Database
121120 // Ensure we have some minimal caching and file guarantees
122121 if cache < minCache {
123122 cache = minCache
@@ -140,6 +139,11 @@ func New(file string, cache int, handles int, namespace string, readonly bool) (
140139 if memTableSize > maxMemTableSize {
141140 memTableSize = maxMemTableSize
142141 }
142+ db := & Database {
143+ fn : file ,
144+ log : logger ,
145+ quitChan : make (chan chan error ),
146+ }
143147 opt := & pebble.Options {
144148 // Pebble has a single combined cache area and the write
145149 // 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) (
187191 if err != nil {
188192 return nil , err
189193 }
190- // Assemble the wrapper with all the registered metrics
191- db = & Database {
192- fn : file ,
193- db : innerDB ,
194- log : logger ,
195- quitChan : make (chan chan error ),
196- }
194+ db .db = innerDB
195+
197196 db .compTimeMeter = metrics .NewRegisteredMeter (namespace + "compact/time" , nil )
198197 db .compReadMeter = metrics .NewRegisteredMeter (namespace + "compact/input" , nil )
199198 db .compWriteMeter = metrics .NewRegisteredMeter (namespace + "compact/output" , nil )
0 commit comments