aboutsummaryrefslogtreecommitdiff
path: root/tx.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2016-01-11 14:47:01 -0700
committerBen Johnson <benbjohnson@yahoo.com>2016-01-11 14:47:01 -0700
commit694a82a9595845d376dd19ff5c24cab78801204b (patch)
tree19c30005f6e3c46c78eb582e9f28f8af81d24d10 /tx.go
parentMerge pull request #479 from azazeal/master (diff)
parentdo not grow dbsize agressively (diff)
downloaddedo-694a82a9595845d376dd19ff5c24cab78801204b.tar.gz
dedo-694a82a9595845d376dd19ff5c24cab78801204b.tar.xz
Merge branch 'grow' of https://github.com/xiang90/bolt into xiang90-grow
Diffstat (limited to 'tx.go')
-rw-r--r--tx.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/tx.go b/tx.go
index 5f4c9f0..395dce3 100644
--- a/tx.go
+++ b/tx.go
@@ -168,6 +168,8 @@ func (tx *Tx) Commit() error {
// Free the old root bucket.
tx.meta.root.root = tx.root.root
+ opgid := tx.meta.pgid
+
// 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).
tx.db.freelist.free(tx.meta.txid, tx.db.page(tx.meta.freelist))
@@ -182,6 +184,10 @@ func (tx *Tx) Commit() error {
}
tx.meta.freelist = p.id
+ if tx.meta.pgid > opgid {
+ tx.db.growSize(int(tx.meta.pgid+1) * tx.db.pageSize)
+ }
+
// Write dirty pages to disk.
startTime = time.Now()
if err := tx.write(); err != nil {