summaryrefslogtreecommitdiff
path: root/src/btree/bt_discard.c
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2014-02-19 18:45:25 -0500
committerKeith Bostic <keith@wiredtiger.com>2014-02-19 18:45:25 -0500
commite4c35d5705317361f0f84d4ee9019d3641dbf101 (patch)
treee24c26e65793f397740988b23af115e96e7479d9 /src/btree/bt_discard.c
parentc0706ebb5832be4f0848d864e43239f5ebfde8a6 (diff)
downloadmongo-e4c35d5705317361f0f84d4ee9019d3641dbf101.tar.gz
WT_REF arrays have to be processed when the page is discarded: we can't
using the "index" array, because for internal splits that deepend the tree, and for the single "split" page that disappears during split into a parent, the "index" array won't reference all of the possible WT_REF elements. For now: copy WT_REF key/addresses in all cases, so they can be individually freed, and walk the lists of WT_REFs, not the index array.
Diffstat (limited to 'src/btree/bt_discard.c')
-rw-r--r--src/btree/bt_discard.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/btree/bt_discard.c b/src/btree/bt_discard.c
index 6894bde796f..23c7f2bd199 100644
--- a/src/btree/bt_discard.c
+++ b/src/btree/bt_discard.c
@@ -94,7 +94,8 @@ __free_page_modify(WT_SESSION_IMPL *session, WT_PAGE *page)
{
WT_INSERT_HEAD *append;
WT_PAGE_MODIFY *mod;
- uint32_t i;
+ WT_REF *ref;
+ uint32_t i, j;
mod = page->modify;
@@ -119,12 +120,17 @@ __free_page_modify(WT_SESSION_IMPL *session, WT_PAGE *page)
}
/*
- * Free the split chunks; we do not have to review the individual WT_REF
- * entries in the chunks, they are discarded by walking the "final" list
- * of WT_REF entries when each internal page is discarded.
+ * Free the split chunks created when underlying pages split into this
+ * page.
*/
- for (i = 0; i < mod->splits_slots; ++i)
- __wt_free(session, mod->splits[i]);
+ for (i = 0; i < mod->splits_slots; ++i) {
+ if ((ref = mod->splits[i].refs) == NULL)
+ break;
+ for (j = mod->splits[i].entries; j > 0; ++ref, --j)
+ __wt_free_ref(session, page, ref);
+ __wt_free(session, mod->splits[i].refs);
+ }
+ __wt_free(session, mod->splits);
/* Free the reconciliation-created array of split pages. */
__wt_free(session, mod->split_ref);
@@ -152,32 +158,13 @@ __free_page_modify(WT_SESSION_IMPL *session, WT_PAGE *page)
}
/*
- * __free_page_col_var --
- * Discard a WT_PAGE_COL_VAR page.
- */
-static void
-__free_page_col_var(WT_SESSION_IMPL *session, WT_PAGE *page)
-{
- /* Free the RLE lookup array. */
- __wt_free(session, page->pu_var_repeats);
-}
-
-/*
* __free_page_int --
* Discard a WT_PAGE_ROW_INT page.
*/
static void
__free_page_int(WT_SESSION_IMPL *session, WT_PAGE *page)
{
- WT_REF *ref;
-
- /* Free the contents of any WT_REF structures. */
- if (page->pu_intl_index != NULL) {
- WT_INTL_FOREACH_BEGIN(page, ref) {
- __wt_free_ref(session, page, ref);
- } WT_INTL_FOREACH_END;
- __wt_free(session, page->pu_intl_index);
- }
+ __wt_free(session, page->pu_intl_index);
}
/*
@@ -215,6 +202,17 @@ __wt_free_ref(WT_SESSION_IMPL *session, WT_PAGE *page, WT_REF *ref)
}
/*
+ * __free_page_col_var --
+ * Discard a WT_PAGE_COL_VAR page.
+ */
+static void
+__free_page_col_var(WT_SESSION_IMPL *session, WT_PAGE *page)
+{
+ /* Free the RLE lookup array. */
+ __wt_free(session, page->pu_var_repeats);
+}
+
+/*
* __free_page_row_leaf --
* Discard a WT_PAGE_ROW_LEAF page.
*/