summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2015-10-30 22:18:27 +1100
committerAlex Gorrod <alexg@wiredtiger.com>2015-11-24 05:05:46 +0000
commit7b1398a1a6ee6bd4e0624c38c5311e896a42cbfc (patch)
tree36e6c275513a99a0c3701f6f0f16d4c90dab04aa
parent155ad1a5f86affdd9bdba17787c7bb801308a2ca (diff)
downloadmongo-7b1398a1a6ee6bd4e0624c38c5311e896a42cbfc.tar.gz
Merge pull request #2278 from wiredtiger/SERVER-21027-fix
SERVER-21027 Don't leave empty internal pages in the tree (cherry picked from commit ba931c1)
-rw-r--r--src/btree/bt_split.c17
-rw-r--r--src/evict/evict_file.c10
-rw-r--r--src/include/txn.i7
-rw-r--r--src/reconcile/rec_write.c1
4 files changed, 15 insertions, 20 deletions
diff --git a/src/btree/bt_split.c b/src/btree/bt_split.c
index 82a4dac226f..d2861e5237e 100644
--- a/src/btree/bt_split.c
+++ b/src/btree/bt_split.c
@@ -960,17 +960,11 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref,
result_entries = (parent_entries + new_entries) - deleted_entries;
/*
- * If the entire (sub)tree is empty, leave the first ref in place,
- * deleted.
+ * If the entire (sub)tree is empty, give up: we can't leave an empty
+ * internal page.
*/
- if (result_entries == 0) {
- next_ref = pindex->index[0];
- WT_ASSERT(session, next_ref->state == WT_REF_SPLIT ||
- (next_ref == ref && ref->state == WT_REF_LOCKED));
- next_ref->state = WT_REF_DELETED;
- --deleted_entries;
- result_entries = 1;
- }
+ if (result_entries == 0)
+ return (0);
/*
* Allocate and initialize a new page index array for the parent, then
@@ -1016,6 +1010,9 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref,
*alloc_refp++ = next_ref;
}
+ /* Check that we filled in all the entries. */
+ WT_ASSERT(session, alloc_refp - alloc_index->index == result_entries);
+
/*
* Update the parent page's index: this update makes the split visible
* to threads descending the tree.
diff --git a/src/evict/evict_file.c b/src/evict/evict_file.c
index 4cf3840ba8e..ed0ffb5b262 100644
--- a/src/evict/evict_file.c
+++ b/src/evict/evict_file.c
@@ -18,11 +18,8 @@ __wt_evict_file(WT_SESSION_IMPL *session, int syncop)
WT_DECL_RET;
WT_PAGE *page;
WT_REF *next_ref, *ref;
- WT_TXN *txn;
bool evict_reset;
- txn = &session->txn;
-
/*
* We need exclusive access to the file -- disable ordinary eviction
* and drain any blocks already queued.
@@ -32,9 +29,6 @@ __wt_evict_file(WT_SESSION_IMPL *session, int syncop)
/* Make sure the oldest transaction ID is up-to-date. */
__wt_txn_update_oldest(session, true);
- if (txn->isolation == WT_ISO_READ_COMMITTED)
- __wt_txn_get_snapshot(session);
-
/* Walk the tree, discarding pages. */
next_ref = NULL;
WT_ERR(__wt_tree_walk(session, &next_ref, NULL,
@@ -65,10 +59,6 @@ __wt_evict_file(WT_SESSION_IMPL *session, int syncop)
if (syncop == WT_SYNC_CLOSE && __wt_page_is_modified(page))
WT_ERR(__wt_reconcile(session, ref, NULL, WT_EVICTING));
- /* Update our snapshot for each new page. */
- if (txn->isolation == WT_ISO_READ_COMMITTED)
- __wt_txn_get_snapshot(session);
-
/*
* We can't evict the page just returned to us (it marks our
* place in the tree), so move the walk to one page ahead of
diff --git a/src/include/txn.i b/src/include/txn.i
index 3152ff6bdd5..73d7f1f0518 100644
--- a/src/include/txn.i
+++ b/src/include/txn.i
@@ -187,6 +187,13 @@ __wt_txn_visible(WT_SESSION_IMPL *session, uint64_t id)
session->dhandle == session->meta_dhandle)
return (true);
+ /*
+ * If we don't have a transactional snapshot, only make stable updates
+ * visible.
+ */
+ if (!F_ISSET(txn, WT_TXN_HAS_SNAPSHOT))
+ return (__wt_txn_visible_all(session, id));
+
/* Transactions see their own changes. */
if (id == txn->id)
return (true);
diff --git a/src/reconcile/rec_write.c b/src/reconcile/rec_write.c
index 988b7e0a84f..73b7f4968e9 100644
--- a/src/reconcile/rec_write.c
+++ b/src/reconcile/rec_write.c
@@ -653,6 +653,7 @@ __rec_write_init(WT_SESSION_IMPL *session,
r->flags = flags;
/* Track if the page can be marked clean. */
+ r->max_txn = WT_TXN_NONE;
r->leave_dirty = false;
/* Raw compression. */