diff --git a/kv/util/engine_util/engines.go b/kv/util/engine_util/engines.go index 8ece21bd5..2ec497d52 100644 --- a/kv/util/engine_util/engines.go +++ b/kv/util/engine_util/engines.go @@ -38,11 +38,14 @@ func (en *Engines) WriteRaft(wb *WriteBatch) error { } func (en *Engines) Close() error { - if err := en.Kv.Close(); err != nil { - return err - } - if err := en.Raft.Close(); err != nil { - return err + dbs := []*badger.DB{en.Kv, en.Raft} + for _, db := range dbs { + if db == nil { + continue + } + if err := db.Close(); err != nil { + return err + } } return nil }