Skip to content

Commit

Permalink
fix the deadlock when closing db (#164)
Browse files Browse the repository at this point in the history
A bug was found when running benchmark, which has been solved.
  • Loading branch information
KANIOYH authored Jul 1, 2024
1 parent 3c9041a commit 3082d67
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ func Open(options Options) (*DB, error) {
// Set the closed flag to true.
// The DB instance cannot be used after closing.
func (db *DB) Close() error {
db.mu.Lock()
defer db.mu.Unlock()
close(db.flushChan)
<-db.closeChan
db.mu.Lock()
defer db.mu.Unlock()
// close all memtables
for _, table := range db.immuMems {
if err := table.close(); err != nil {
Expand Down

0 comments on commit 3082d67

Please sign in to comment.