Skip to content

Commit

Permalink
Fix: it is possible that a big inner node will cascadb down multiple …
Browse files Browse the repository at this point in the history
…times
  • Loading branch information
weicao committed Mar 19, 2013
1 parent 18f527d commit 062ee0d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/tree/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void InnerNode::maybe_cascade()
unlock();
return;
}

assert(idx >= 0);
MsgBuf* b = msgbuf(idx);
bid_t nid = child(idx);
Expand All @@ -315,6 +315,16 @@ void InnerNode::maybe_cascade()
assert(node);
node->cascade(b, this);
node->dec_ref();

// it's possible to cascade twice
// lock is released in child, so it's nescessarty to obtain it again
read_lock();
if (msgcnt_ >= tree_->options_.inner_node_msg_count ||
size() >= tree_->options_.inner_node_page_size) {
maybe_cascade();
} else {
unlock();
}
}

void InnerNode::add_pivot(Slice key, bid_t nid, std::vector<DataNode*>& path)
Expand Down

0 comments on commit 062ee0d

Please sign in to comment.