mirror of https://github.com/etcd-io/bbolt.git
test: check free page counts on close/reopen for freelist overflow
Confirm that the number of freed pages exceeds the overflow count, then check that reopening gives the same number of free pages.pull/12/head
parent
2ab139b399
commit
f50ad8e90c
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue