diff --git a/cmd/accumulated/run/core_validator.go b/cmd/accumulated/run/core_validator.go index c625542c2..faedf20a2 100644 --- a/cmd/accumulated/run/core_validator.go +++ b/cmd/accumulated/run/core_validator.go @@ -18,7 +18,6 @@ import ( func (c *CoreValidatorConfiguration) apply(_ *Instance, cfg *Config) error { // Set core validator defaults setDefaultPtr(&c.StorageType, StorageTypeBadger) - setDefaultPtr(&c.EnableSnapshots, false) // Validate if c.Listen == nil { @@ -116,6 +115,8 @@ type partOpts struct { } func (p partOpts) apply(cfg *Config) error { + setDefaultPtr(&p.EnableSnapshots, false) + // Consensus addService(cfg, &ConsensusService{ diff --git a/pkg/database/keyvalue/leveldb/database.go b/pkg/database/keyvalue/leveldb/database.go index 225af574e..ac1b1785e 100644 --- a/pkg/database/keyvalue/leveldb/database.go +++ b/pkg/database/keyvalue/leveldb/database.go @@ -69,7 +69,6 @@ func (d *Database) Begin(prefix *record.Key, writable bool) keyvalue.ChangeSet { if d.closing.Load() { err = errors.Conflict.With("closed") } else { - d.open.Add(1) snap, err = d.leveldb.GetSnapshot() } @@ -90,8 +89,10 @@ func (d *Database) Begin(prefix *record.Key, writable bool) keyvalue.ChangeSet { discard := func() {} if err == nil { + d.open.Add(1) + var once sync.Once discard = func() { - defer d.open.Done() + defer once.Do(d.open.Done) snap.Release() } }