summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSusan LoVerso <sue@wiredtiger.com>2015-12-28 14:11:10 -0500
committerSusan LoVerso <sue@wiredtiger.com>2015-12-28 14:11:10 -0500
commit2427cd486745f4bac50d0482fa4878e70c8e3950 (patch)
treec4e016034c759fb9feda7d1d52fc8374c171b5d2
parent12aaeb6ad9ce1cebba26bcfb96613ccad7eda78e (diff)
downloadmongo-2427cd486745f4bac50d0482fa4878e70c8e3950.tar.gz
WT-2307 Use single enum for split error handling phases.
-rw-r--r--src/btree/bt_split.c28
-rw-r--r--src/include/btmem.h15
2 files changed, 29 insertions, 14 deletions
diff --git a/src/btree/bt_split.c b/src/btree/bt_split.c
index 3046316bf8b..684388e47d9 100644
--- a/src/btree/bt_split.c
+++ b/src/btree/bt_split.c
@@ -512,6 +512,7 @@ __split_root(WT_SESSION_IMPL *session, WT_PAGE *root)
WT_PAGE_INDEX *alloc_index, *child_pindex, *pindex;
WT_REF **alloc_refp;
WT_REF **child_refp, *ref, **root_refp;
+ WT_SPLIT_ERROR_PHASE complete;
size_t child_incr, root_decr, root_incr, size;
uint64_t split_gen;
uint32_t children, chunk, i, j, remain;
@@ -529,7 +530,6 @@ __split_root(WT_SESSION_IMPL *session, WT_PAGE *root)
* ignore most errors because the split is complete and correct, callers
* have to proceed accordingly.
*/
- enum { ERR_RETURN, ERR_PANIC, ERR_IGNORE } complete;
WT_STAT_FAST_CONN_INCR(session, cache_eviction_deepen);
WT_STAT_FAST_DATA_INCR(session, cache_eviction_deepen);
@@ -539,7 +539,7 @@ __split_root(WT_SESSION_IMPL *session, WT_PAGE *root)
btree = S2BT(session);
alloc_index = NULL;
root_decr = root_incr = 0;
- complete = ERR_RETURN;
+ complete = WT_ERR_RETURN;
/* The root page will be marked dirty, make sure that will succeed. */
WT_RET(__wt_page_modify_init(session, root));
@@ -641,7 +641,7 @@ __split_root(WT_SESSION_IMPL *session, WT_PAGE *root)
root_refp - pindex->index == (ptrdiff_t)pindex->entries);
/* Start making real changes to the tree, errors are fatal. */
- complete = ERR_PANIC;
+ complete = WT_ERR_PANIC;
/* Prepare the WT_REFs for the move. */
__split_ref_step1(session, alloc_index, false);
@@ -661,7 +661,7 @@ __split_root(WT_SESSION_IMPL *session, WT_PAGE *root)
WT_ERR(__split_ref_step2(session, alloc_index, false));
/* The split is complete and correct, ignore benign errors. */
- complete = ERR_IGNORE;
+ complete = WT_ERR_IGNORE;
/* We've installed the allocated page-index, ensure error handling. */
alloc_index = NULL;
@@ -687,15 +687,15 @@ __split_root(WT_SESSION_IMPL *session, WT_PAGE *root)
__wt_page_modify_set(session, root);
err: switch (complete) {
- case ERR_RETURN:
+ case WT_ERR_RETURN:
__wt_free_ref_index(session, root, alloc_index, true);
break;
- case ERR_PANIC:
+ case WT_ERR_PANIC:
__wt_err(session, ret,
"fatal error during root page split to deepen the tree");
ret = WT_PANIC;
break;
- case ERR_IGNORE:
+ case WT_ERR_IGNORE:
if (ret != 0 && ret != WT_PANIC) {
__wt_err(session, ret,
"ignoring not-fatal error during root page split "
@@ -992,6 +992,7 @@ __split_internal(WT_SESSION_IMPL *session, WT_PAGE *parent, WT_PAGE *page)
WT_PAGE_INDEX *alloc_index, *child_pindex, *pindex, *replace_index;
WT_REF **alloc_refp;
WT_REF **child_refp, *page_ref, **page_refp, *ref;
+ WT_SPLIT_ERROR_PHASE complete;
size_t child_incr, page_decr, page_incr, parent_incr, size;
uint64_t split_gen;
uint32_t children, chunk, i, j, remain;
@@ -1009,7 +1010,6 @@ __split_internal(WT_SESSION_IMPL *session, WT_PAGE *parent, WT_PAGE *page)
* ignore most errors because the split is complete and correct, callers
* have to proceed accordingly.
*/
- enum { ERR_RETURN, ERR_PANIC, ERR_IGNORE } complete;
WT_STAT_FAST_CONN_INCR(session, cache_eviction_split_internal);
WT_STAT_FAST_DATA_INCR(session, cache_eviction_split_internal);
@@ -1021,7 +1021,7 @@ __split_internal(WT_SESSION_IMPL *session, WT_PAGE *parent, WT_PAGE *page)
alloc_index = replace_index = NULL;
page_ref = page->pg_intl_parent_ref;
page_decr = page_incr = parent_incr = 0;
- complete = ERR_RETURN;
+ complete = WT_ERR_RETURN;
/*
* Our caller is holding the page locked to single-thread splits, which
@@ -1142,7 +1142,7 @@ __split_internal(WT_SESSION_IMPL *session, WT_PAGE *parent, WT_PAGE *page)
page_refp - pindex->index == (ptrdiff_t)pindex->entries);
/* Start making real changes to the tree, errors are fatal. */
- complete = ERR_PANIC;
+ complete = WT_ERR_PANIC;
/* Prepare the WT_REFs for the move. */
__split_ref_step1(session, alloc_index, true);
@@ -1166,7 +1166,7 @@ __split_internal(WT_SESSION_IMPL *session, WT_PAGE *parent, WT_PAGE *page)
WT_ERR(__split_ref_step2(session, alloc_index, true));
/* The split is complete and correct, ignore benign errors. */
- complete = ERR_IGNORE;
+ complete = WT_ERR_IGNORE;
/*
* Push out the changes: not required for correctness, but no reason
@@ -1202,16 +1202,16 @@ __split_internal(WT_SESSION_IMPL *session, WT_PAGE *parent, WT_PAGE *page)
__wt_page_modify_set(session, page);
err: switch (complete) {
- case ERR_RETURN:
+ case WT_ERR_RETURN:
__wt_free_ref_index(session, page, alloc_index, true);
__wt_free_ref_index(session, page, replace_index, false);
break;
- case ERR_PANIC:
+ case WT_ERR_PANIC:
__wt_err(session, ret,
"fatal error during internal page split");
ret = WT_PANIC;
break;
- case ERR_IGNORE:
+ case WT_ERR_IGNORE:
if (ret != 0 && ret != WT_PANIC) {
__wt_err(session, ret,
"ignoring not-fatal error during internal page "
diff --git a/src/include/btmem.h b/src/include/btmem.h
index 12a736c56a2..a04f17fe7d3 100644
--- a/src/include/btmem.h
+++ b/src/include/btmem.h
@@ -1062,3 +1062,18 @@ struct __wt_insert_head {
WT_ENTER_PAGE_INDEX(session); \
(e); \
WT_LEAVE_PAGE_INDEX(session)
+
+/*
+ * Some split functions need special error handling. Failures that occur
+ * during the WT_ERR_IGNORE phase will ignore most errors because the split
+ * is complete and correct. Errors during the WT_ERR_PANIC phase are
+ * catastrophic. The split is a partial update to the tree and requires a
+ * panic. Errors during the WT_ERR_RETURN phase will discard resources
+ * and return the error.
+ */
+typedef enum __wt_split_error_phase {
+ WT_ERR_IGNORE,
+ WT_ERR_PANIC,
+ WT_ERR_RETURN
+} WT_SPLIT_ERROR_PHASE;
+