Skip to content

Commit 685b55e

Browse files
committed
fix: panic in the main hierarchy
1 parent c1227ce commit 685b55e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

db.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,14 +1253,19 @@ func (db *DB) freepages() []common.Pgid {
12531253
reachable := make(map[common.Pgid]*common.Page)
12541254
nofreed := make(map[common.Pgid]bool)
12551255
ech := make(chan error)
1256+
1257+
var wg sync.WaitGroup
1258+
1259+
wg.Add(1)
12561260
go func() {
1257-
for e := range ech {
1258-
panic(fmt.Sprintf("freepages: failed to get all reachable pages (%v)", e))
1259-
}
1261+
defer wg.Done()
1262+
tx.recursivelyCheckBucket(&tx.root, reachable, nofreed, HexKVStringer(), ech)
1263+
close(ech)
12601264
}()
1261-
tx.recursivelyCheckBucket(&tx.root, reachable, nofreed, HexKVStringer(), ech)
1262-
close(ech)
1263-
1265+
for e := range ech {
1266+
panic(fmt.Sprintf("freepages: failed to get all reachable pages (%v)", e))
1267+
}
1268+
wg.Wait()
12641269
// TODO: If check bucket reported any corruptions (ech) we shouldn't proceed to freeing the pages.
12651270

12661271
var fids []common.Pgid

0 commit comments

Comments
 (0)