diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2016-11-14 09:36:40 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-14 09:36:40 +1100 |
commit | 05e9389be80f28a63327d62d3d2e2eb1ecc3e14b (patch) | |
tree | c3a9fc27b7a75d8841866d3b8281c9f48307e3a3 | |
parent | 17c567ee479c4689eebc62515fd1aae58dca9603 (diff) | |
download | mongo-05e9389be80f28a63327d62d3d2e2eb1ecc3e14b.tar.gz |
WT-3012 Check a btree is LSM primary before switching. (#3143)
-rw-r--r-- | src/include/btree.i | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/include/btree.i b/src/include/btree.i index 6fe2a101f48..9c8ec1dbdea 100644 --- a/src/include/btree.i +++ b/src/include/btree.i @@ -1562,27 +1562,36 @@ __wt_btree_lsm_switch_primary(WT_SESSION_IMPL *session, bool on) cache = S2C(session)->cache; root = btree->root.page; - if (on) { - F_SET(btree, WT_BTREE_LSM_PRIMARY); - F_SET(btree, WT_BTREE_NO_EVICTION); - } else { + if (on && !F_ISSET(btree, WT_BTREE_LSM_PRIMARY)) + F_SET(btree, WT_BTREE_LSM_PRIMARY | WT_BTREE_NO_EVICTION); + if (!on && F_ISSET(btree, WT_BTREE_LSM_PRIMARY)) { pindex = WT_INTL_INDEX_GET_SAFE(root); + if (!F_ISSET(btree, WT_BTREE_NO_EVICTION) || + pindex->entries != 1) + return; first = pindex->index[0]; - /* - * We're reaching down into the page without a hazard pointer, but - * that's OK because we know that no-eviction is set and so the page - * cannot disappear. - */ + /* + * We're reaching down into the page without a hazard pointer, + * but that's OK because we know that no-eviction is set so the + * page can't disappear. + */ child = first->page; - if (!__wt_page_is_modified(child)) + if (first->state != WT_REF_MEM || + child->type != WT_PAGE_ROW_LEAF || + !__wt_page_is_modified(child)) return; + + /* + * While this tree was the primary, its dirty bytes were not + * included in the cache accounting. Fix that now before we + * open it up for eviction. + */ size = child->modify->bytes_dirty; (void)__wt_atomic_add64(&btree->bytes_dirty_leaf, size); (void)__wt_atomic_add64(&cache->bytes_dirty_leaf, size); - F_CLR(btree, WT_BTREE_LSM_PRIMARY); - F_CLR(btree, WT_BTREE_NO_EVICTION); + F_CLR(btree, WT_BTREE_LSM_PRIMARY | WT_BTREE_NO_EVICTION); } } |