aboutsummaryrefslogtreecommitdiff
path: root/tx.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-03-31 08:52:13 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-03-31 08:52:19 -0600
commit440b89418f5907099cf06764ad7f2b83cf12fbcf (patch)
tree6b0b06f7fc1ca4c4799ebb480961ed297bf9667b /tx.go
parentMerge pull request #98 from benbjohnson/fsck (diff)
downloaddedo-440b89418f5907099cf06764ad7f2b83cf12fbcf.tar.gz
dedo-440b89418f5907099cf06764ad7f2b83cf12fbcf.tar.xz
Write freelist after each commit.
Well, this is embarassing. Somehow the freelist was never getting written after each commit. This commit fixes that and fixes a small reporting issue with "bolt pages".
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