-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix link version upgrade and enable it #205
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,13 +69,11 @@ btree_status_t Btree< K, V >::get_child_and_lock_node(const BtreeNodePtr& node, | |
locktype_t int_lock_type, locktype_t leaf_lock_type, | ||
void* context) const { | ||
if (index == node->total_entries()) { | ||
const auto& edge_id{node->edge_id()}; | ||
child_info.set_bnode_id(edge_id); | ||
// If bsearch points to last index, it means the search has not found entry unless it is an edge value. | ||
if (!child_info.has_valid_bnode_id()) { | ||
if (!node->has_valid_edge()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: call has_valid_edge() instead of has_valid_bnode_id |
||
BT_NODE_LOG_ASSERT(false, node, "Child index {} does not have valid bnode_id", index); | ||
return btree_status_t::not_found; | ||
} | ||
child_info = node->get_edge_value(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to non-edge child (i.e., |
||
} else { | ||
BT_NODE_LOG_ASSERT_LT(index, node->total_entries(), node); | ||
node->get_nth_value(index, &child_info, false /* copy */); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -528,13 +528,14 @@ btree_status_t Btree< K, V >::merge_nodes(const BtreeNodePtr& parent_node, const | |
// Finally update the leftmost node with latest key | ||
leftmost_node->set_next_bnode(next_node_id); | ||
if (leftmost_node->total_entries()) { | ||
// leftmost_node->inc_link_version(); | ||
leftmost_node->inc_link_version(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. enable the the increase link version of left most node in merge |
||
parent_node->update(start_idx, leftmost_node->get_last_key< K >(), leftmost_node->link_info()); | ||
} | ||
|
||
if (parent_node->total_entries() && !parent_node->has_valid_edge()) { | ||
if (parent_node->compare_nth_key(plast_key, parent_node->total_entries() - 1)) { | ||
auto last_node = new_nodes.size() > 0 ? new_nodes[new_nodes.size() - 1] : leftmost_node; | ||
last_node->inc_link_version(); | ||
parent_node->update(parent_node->total_entries() - 1, plast_key, last_node->link_info()); | ||
} | ||
} | ||
|
@@ -567,6 +568,28 @@ btree_status_t Btree< K, V >::merge_nodes(const BtreeNodePtr& parent_node, const | |
#ifndef NDEBUG | ||
// BT_DBG_ASSERT(!parent_node_step1.empty() && !parent_node_step2.empty() && !parent_node_step3.empty(), | ||
// "Empty string"); | ||
// check if the link version of parent for each key info match the link version of its child | ||
BtreeLinkInfo child_info; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. validate the link version of updated parent keys and that of its children match |
||
if (ret == btree_status_t::success) { | ||
for (uint32_t idx = 0; idx < new_nodes.size(); idx++) { | ||
parent_node->get_nth_value(start_idx + 1 + idx, &child_info, false /* copy */); | ||
BT_NODE_DBG_ASSERT_EQ(child_info.link_version(), new_nodes[idx]->link_version(), parent_node, | ||
"mismatch of link version of new nodes in successful merge"); | ||
} | ||
parent_node->get_nth_value(start_idx, &child_info, false /* copy */); | ||
BT_NODE_DBG_ASSERT_EQ(child_info.link_version(), leftmost_node->link_version(), parent_node, | ||
"parent_node, mismatch of link version of leftmost node in successful merge"); | ||
} else { | ||
for (uint32_t idx = 0; idx < old_nodes.size(); idx++) { | ||
parent_node->get_nth_value(start_idx + 1 + idx, &child_info, false /* copy */); | ||
BT_NODE_DBG_ASSERT_EQ(child_info.link_version(), old_nodes[idx]->link_version(), parent_node, | ||
"mismatch of link version of old nodes in unsuccessful merge"); | ||
} | ||
parent_node->get_nth_value(start_idx, &child_info, false /* copy */); | ||
BT_NODE_DBG_ASSERT_EQ(child_info.link_version(), leftmost_node->link_version(), parent_node, | ||
"parent_node, mismatch of link version of leftmost node in unsuccessful merge"); | ||
} | ||
|
||
if (leftmost_node->total_entries() && (start_idx < parent_node->total_entries())) { | ||
BT_NODE_DBG_ASSERT_LE( | ||
leftmost_node->get_last_key< K >().compare(parent_node->get_nth_key< K >(start_idx, false)), 0, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edge link version needed to chat instead of the node link version