mirror of https://github.com/etcd-io/bbolt.git
Merge pull request #12 from heyitsanthony/skip-freelist-overflow
freelist: read all free pages on count overflowpull/17/head v1.3.1-coreos.0
commit
12923fe56c
|
@ -423,6 +423,22 @@ func TestBucket_Delete_FreelistOverflow(t *testing.T) {
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check more than an overflow's worth of pages are freed.
|
||||||
|
stats := db.Stats()
|
||||||
|
freePages := stats.FreePageN + stats.PendingPageN
|
||||||
|
if freePages <= 0xFFFF {
|
||||||
|
t.Fatalf("expected more than 0xFFFF free pages, got %v", freePages)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Free page count should be preserved on reopen.
|
||||||
|
if err := db.DB.Close(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
db.MustReopen()
|
||||||
|
if reopenFreePages := db.Stats().FreePageN; freePages != reopenFreePages {
|
||||||
|
t.Fatalf("expected %d free pages, got %+v", freePages, db.Stats())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that accessing and updating nested buckets is ok across transactions.
|
// Ensure that accessing and updating nested buckets is ok across transactions.
|
||||||
|
|
|
@ -245,7 +245,7 @@ func (f *freelist) read(p *page) {
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
f.ids = nil
|
f.ids = nil
|
||||||
} else {
|
} else {
|
||||||
ids := ((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[idx:count]
|
ids := ((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[idx:idx+count]
|
||||||
f.ids = make([]pgid, len(ids))
|
f.ids = make([]pgid, len(ids))
|
||||||
copy(f.ids, ids)
|
copy(f.ids, ids)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue