Skip to content

Commit

Permalink
*: clean up txPool even on error (#914)
Browse files Browse the repository at this point in the history
This would otherwise leak goroutines if an error was encountered closing the
WAL.
  • Loading branch information
asubiotto authored Jun 26, 2024
1 parent 39c2018 commit 56013c3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -1000,16 +1000,17 @@ func (db *DB) Close(options ...CloseOption) error {
}

func (db *DB) closeInternal() error {
if db.columnStore.enableWAL && db.wal != nil {
if err := db.wal.Close(); err != nil {
return err
defer func() {
// Clean up the txPool even on error.
if db.txPool != nil {
db.txPool.Stop()
}
}
if db.txPool != nil {
db.txPool.Stop()
}
}()

return nil
if !db.columnStore.enableWAL || db.wal == nil {
return nil
}
return db.wal.Close()
}

func (db *DB) maintainWAL() {
Expand Down

0 comments on commit 56013c3

Please sign in to comment.