aboutsummaryrefslogtreecommitdiff
path: root/node.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-07-23 15:44:17 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-07-23 15:44:17 -0600
commit5fb781318ffe555f3eac13c2dee677e1a278828a (patch)
treed9a6eb8f34baf289c8cb931620bb4e8d32b704a0 /node.go
parentMerge pull request #227 from benbjohnson/fix-double-spill (diff)
parentFix root split on very large append. (diff)
downloaddedo-5fb781318ffe555f3eac13c2dee677e1a278828a.tar.gz
dedo-5fb781318ffe555f3eac13c2dee677e1a278828a.tar.xz
Merge pull request #228 from benbjohnson/fix-large-append
Fix root split on very large append.
Diffstat (limited to 'node.go')
-rw-r--r--node.go21
1 files changed, 7 insertions, 14 deletions
diff --git a/node.go b/node.go
index cda5201..75433ad 100644
--- a/node.go
+++ b/node.go
@@ -188,6 +188,8 @@ func (n *node) write(p *page) {
} else {
p.flags |= branchPageFlag
}
+
+ _assert(len(n.inodes) < 0xFFFF, "inode overflow: %d (pgid=%d)", len(n.inodes), p.id)
p.count = uint16(len(n.inodes))
// Loop over each item and write it to the page.
@@ -367,20 +369,11 @@ func (n *node) spill() error {
tx.stats.Spill++
}
- // This is a special case where we need to write the parent if it is new
- // and caused by a split in the root.
- var parent = n.parent
- if parent != nil && parent.pgid == 0 {
- // Allocate contiguous space for the node.
- p, err := tx.allocate((parent.size() / tx.db.pageSize) + 1)
- if err != nil {
- return err
- }
-
- // Write the new root.
- _assert(p.id < tx.meta.pgid, "pgid (%d) above high water mark (%d)", p.id, tx.meta.pgid)
- parent.pgid = p.id
- parent.write(p)
+ // If the root node split and created a new root then we need to spill that
+ // as well. We'll clear out the children to make sure it doesn't try to respill.
+ if n.parent != nil && n.parent.pgid == 0 {
+ n.children = nil
+ return n.parent.spill()
}
return nil