Skip to content

Commit

Permalink
fix: handle nil *badger.DB in *Engines.Close (#398)
Browse files Browse the repository at this point in the history
Co-authored-by: Connor <[email protected]>
  • Loading branch information
mind1949 and Connor1996 authored Jul 6, 2022
1 parent dae8650 commit d975005
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions kv/util/engine_util/engines.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit d975005

Please sign in to comment.