Skip to content

Commit a0d4903

Browse files
author
Ibrahim Jarif
authored
fix(cleanup): Do not close cache before compaction (#1464) (#1488)
This PR fixes a panic that could happen in case `vlog.Open` returns an error. The `db.Cleanup` would close the cache before compaction would finish and as a result of that we will end up with `send of closed channel panic` in ristretto. (cherry picked from commit edbc380)
1 parent bc243f3 commit a0d4903

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

db.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,11 @@ func Open(opt Options) (db *DB, err error) {
427427
// cleanup stops all the goroutines started by badger. This is used in open to
428428
// cleanup goroutines in case of an error.
429429
func (db *DB) cleanup() {
430-
db.blockCache.Close()
431-
db.indexCache.Close()
432430
db.stopMemoryFlush()
433431
db.stopCompactions()
434432

433+
db.blockCache.Close()
434+
db.indexCache.Close()
435435
if db.closers.updateSize != nil {
436436
db.closers.updateSize.Signal()
437437
}
@@ -1024,7 +1024,7 @@ func (db *DB) pushHead(ft flushTask) error {
10241024
}
10251025

10261026
// Store badger head even if vptr is zero, need it for readTs
1027-
db.opt.Debugf("Storing value log head: %+v\n", ft.vptr)
1027+
db.opt.Infof("Storing value log head: %+v\n", ft.vptr)
10281028
val := ft.vptr.Encode()
10291029

10301030
// Pick the max commit ts, so in case of crash, our read ts would be higher than all the

0 commit comments

Comments
 (0)