summaryrefslogtreecommitdiff
path: root/src/btree/col_srch.c
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2014-04-23 08:40:23 -0400
committerKeith Bostic <keith@wiredtiger.com>2014-04-23 08:41:36 -0400
commitf373110a6296c0ea0d0f231d983eafd77ece1271 (patch)
tree1d76a50bd917fda4d579c0e948b6250ede886ab3 /src/btree/col_srch.c
parent6cd6c3efd8eeda539931b7d8dadaa98161572ccc (diff)
downloadmongo-f373110a6296c0ea0d0f231d983eafd77ece1271.tar.gz
We don't have to restart the search from the top of the tree after a
page splits; we're holding a hazard pointer on the page's parent and we can simply restart the search in that page. This won't make things any faster, I don't think, but the code makes more sense this way.
Diffstat (limited to 'src/btree/col_srch.c')
-rw-r--r--src/btree/col_srch.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/btree/col_srch.c b/src/btree/col_srch.c
index 6771372242c..600cc5dc54b 100644
--- a/src/btree/col_srch.c
+++ b/src/btree/col_srch.c
@@ -39,11 +39,10 @@ __wt_col_search(WT_SESSION_IMPL *session,
goto leaf_only;
}
-restart:
/* Search the internal pages of the tree. */
parent = child = &btree->root;
for (depth = 2;; ++depth) {
- page = parent->page;
+restart: page = parent->page;
if (page->type != WT_PAGE_COL_INT)
break;
@@ -90,23 +89,20 @@ descend: WT_ASSERT(session, child != NULL);
}
/*
- * Swap the parent page for the child page; if the page splits
- * while we're waiting for it, restart the search, otherwise
- * return on error.
+ * Swap the parent page for the child page. If the page splits
+ * while we're retrieving it, restart the search in the parent
+ * page; otherwise return on error, the swap call ensures we're
+ * holding nothing on failure.
*/
- if ((ret = __wt_page_swap(session, parent, child, 0)) == 0) {
+ switch (ret = __wt_page_swap(session, parent, child, 0)) {
+ case 0:
parent = child;
- continue;
- }
- /*
- * Restart is returned if we find a page that's been split; the
- * held page isn't discarded when restart is returned, discard
- * it and restart the search from the top of the tree.
- */
- if (ret == WT_RESTART &&
- (ret = __wt_page_release(session, parent)) == 0)
+ break;
+ case WT_RESTART:
goto restart;
- return (ret);
+ default:
+ return (ret);
+ }
}
/* Track how deep the tree gets. */