diff options
author | Keith Bostic <keith@wiredtiger.com> | 2014-03-05 10:43:23 -0500 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2014-03-05 10:43:23 -0500 |
commit | 14acc07a4772e0c2833c264c395e1ed25a23dd93 (patch) | |
tree | 42647275df83062bf9df152b49121c01d9dc6dd3 /src/btree | |
parent | fa5b1558707a0957a4a98936c644323dd4b47ec0 (diff) | |
download | mongo-14acc07a4772e0c2833c264c395e1ed25a23dd93.tar.gz |
Change WT_RESTART into an "expected" failure, similar to WT_NOTFOUND
when walking the cache, requires the caller to release the held page.
Diffstat (limited to 'src/btree')
-rw-r--r-- | src/btree/bt_walk.c | 5 | ||||
-rw-r--r-- | src/btree/col_srch.c | 11 | ||||
-rw-r--r-- | src/btree/row_srch.c | 22 |
3 files changed, 23 insertions, 15 deletions
diff --git a/src/btree/bt_walk.c b/src/btree/bt_walk.c index 7abbc994938..d1dd0b45d62 100644 --- a/src/btree/bt_walk.c +++ b/src/btree/bt_walk.c @@ -160,7 +160,7 @@ __tree_walk_read(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp) #undef PAGE_SWAP #define PAGE_SWAP(session, couple, page, ref, flags, ret) do { \ if (((ret) = __wt_page_swap( \ - session, couple, page, ref, 0, flags)) == WT_RESTART) \ + session, couple, page, ref, flags)) == WT_RESTART) \ goto restart; \ } while (0) @@ -278,12 +278,13 @@ ascend: /* * Can this page-swap function return restart because of * a page split? I don't think so (this is an internal * page that's pinned in memory), but I'm not 100% sure. + * Note we're not handling a return of WT_RESTART. */ if (WT_PAGE_IS_ROOT(page)) WT_RET(__wt_page_release(session, couple)); else WT_RET(__wt_page_swap(session, couple, page, - __wt_page_ref(session, page), 1, flags)); + __wt_page_ref(session, page), flags)); *pagep = page; return (0); diff --git a/src/btree/col_srch.c b/src/btree/col_srch.c index c8c842961e9..69850b0edd2 100644 --- a/src/btree/col_srch.c +++ b/src/btree/col_srch.c @@ -92,16 +92,17 @@ descend: WT_ASSERT(session, ref != NULL); * while we're waiting for it, restart the search, otherwise * return on error. */ - if ((ret = - __wt_page_swap(session, page, page, ref, 1, 0)) == 0) { + if ((ret = __wt_page_swap(session, page, page, ref, 0)) == 0) { page = ref->page; continue; } /* - * Restart is returned if we find a page that's been split; - * restart the search from the top of the tree. + * 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) + if (ret == WT_RESTART && + (ret = __wt_page_release(session, page)) == 0) goto restart; return (ret); } diff --git a/src/btree/row_srch.c b/src/btree/row_srch.c index 93e589f6809..f10bba16b4a 100644 --- a/src/btree/row_srch.c +++ b/src/btree/row_srch.c @@ -320,16 +320,17 @@ descend: WT_ASSERT(session, ref != NULL); * return on error, the swap call ensures we're holding nothing * on failure. */ - if ((ret = - __wt_page_swap(session, page, page, ref, 1, 0)) == 0) { + if ((ret = __wt_page_swap(session, page, page, ref, 0)) == 0) { page = ref->page; continue; } /* - * Restart is returned if we find a page that's been split; - * restart the search from the top of the tree. + * 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) + if (ret == WT_RESTART && + (ret = __wt_page_release(session, page)) == 0) goto restart; return (ret); } @@ -488,12 +489,17 @@ restart: * Swap the parent page for the child page; return on error, * the swap function ensures we're holding nothing on failure. */ - if ((ret = - __wt_page_swap(session, page, page, ref, 1, 0)) == 0) { + if ((ret = __wt_page_swap(session, page, page, ref, 0)) == 0) { page = ref->page; continue; } - if (ret == WT_RESTART) + /* + * 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, page)) == 0) goto restart; return (ret); } |