aboutsummaryrefslogtreecommitdiff
path: root/tx.go
diff options
context:
space:
mode:
Diffstat (limited to 'tx.go')
-rw-r--r--tx.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/tx.go b/tx.go
index 3859de2..25cc829 100644
--- a/tx.go
+++ b/tx.go
@@ -199,6 +199,16 @@ func (t *Tx) Commit() error {
t.db.freelist.free(t.id(), t.page(t.meta.buckets))
t.meta.buckets = p.id
+ // Free the freelist and allocate new pages for it. This will overestimate
+ // the size of the freelist but not underestimate the size (which would be bad).
+ t.db.freelist.free(t.id(), t.page(t.meta.freelist))
+ p, err = t.allocate((t.db.freelist.size() / t.db.pageSize) + 1)
+ if err != nil {
+ return err
+ }
+ t.db.freelist.write(p)
+ t.meta.freelist = p.id
+
// Write dirty pages to disk.
if err := t.write(); err != nil {
return err