Skip to content
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

Merged
merged 1 commit into from
Oct 23, 2023
Merged

Fix link version upgrade and enable it #205

merged 1 commit into from
Oct 23, 2023

Conversation

shosseinimotlagh
Copy link
Contributor

@shosseinimotlagh shosseinimotlagh commented Oct 12, 2023

This pull request addresses an issue with link version inconsistency between a parent node and its children after a merge or split operation is performed. This change is necessary to ensure the stability and correctness of the btree during repair/recovery . This is achieved through the following changes:

  1. The value of the link version for the edge is now properly populated and locked when accessed by a caller.
  2. Theget_edge_value()method now returns the correct value for the edge's link version.
  3. The inc_link_version is now enabled in the merge and split methods.
  4. A BT_NODE_DBG_ASSERT_EQ check has been added to validate the change made during merge (split, as it has a trivial algorithm, does not need this validation).

Overall, this pull request ensures that link version stays consistent between parent and children nodes, even after a merge or split operation is performed.

@sanebay
Copy link
Contributor

sanebay commented Oct 13, 2023

Please add comments and add some details in the description

@@ -398,7 +398,7 @@ class BtreeNode : public sisl::ObjLifeCounter< BtreeNode > {
return true;
}

virtual BtreeLinkInfo get_edge_value() const { return BtreeLinkInfo{edge_id(), link_version()}; }
virtual BtreeLinkInfo get_edge_value() const { return BtreeLinkInfo{edge_id(), edge_link_version()}; }
Copy link
Contributor Author

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

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()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to non-edge child (i.e., get_nth_value in the else statement), both child id and link version need to be populated.

@@ -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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable the the increase link version of left most node in merge

@@ -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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

@shosseinimotlagh shosseinimotlagh merged commit 4fb8fed into eBay:master Oct 23, 2023
16 checks passed
@shosseinimotlagh shosseinimotlagh deleted the link_version branch October 23, 2023 20:45
hkadayam pushed a commit to hkadayam/HomeStore that referenced this pull request Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants