Skip to content

Commit

Permalink
fix NoSyncFreelist reachability checking
Browse files Browse the repository at this point in the history
* scan for free pages if freelist page is valid but the db is opened with
  NoSyncFreelist; forces the freelist pages to count as free pages.

* only treat freelist pages as reachable if set to valid pgid

Fixes boltdb#9
  • Loading branch information
Anthony Romano committed Aug 8, 2017
1 parent 2ab139b commit 6435d79
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func Open(path string, mode os.FileMode, options *Options) (*DB, error) {
}

db.freelist = newFreelist()
noFreeList := db.meta().freelist == pgidNoFreelist
noFreeList := db.meta().freelist == pgidNoFreelist || db.NoFreelistSync
if noFreeList {
// Reconstruct free list by scanning the DB.
db.freelist.readIDs(db.freepages())
Expand Down
2 changes: 1 addition & 1 deletion tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (tx *Tx) check(ch chan error) {
reachable := make(map[pgid]*page)
reachable[0] = tx.page(0) // meta0
reachable[1] = tx.page(1) // meta1
if !tx.DB().NoFreelistSync {
if tx.meta.freelist != pgidNoFreelist {
for i := uint32(0); i <= tx.page(tx.meta.freelist).overflow; i++ {
reachable[tx.meta.freelist+pgid(i)] = tx.page(tx.meta.freelist)
}
Expand Down

0 comments on commit 6435d79

Please sign in to comment.