diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2016-08-02 11:36:55 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-02 11:36:55 +1000 |
commit | 8f02a158b584534fc698cf93cefae85727db902b (patch) | |
tree | d06dbd4119b612daff27759e712903ee964b1ee9 | |
parent | 81ed363cac52374e5f39b4f0906ebde9979d92a5 (diff) | |
download | mongo-8f02a158b584534fc698cf93cefae85727db902b.tar.gz |
WT-2801 Prevent eviction of metadata updates by a running checkpoint. (#2922)
-rw-r--r-- | src/btree/bt_sync.c | 40 | ||||
-rw-r--r-- | src/txn/txn_ckpt.c | 38 |
2 files changed, 40 insertions, 38 deletions
diff --git a/src/btree/bt_sync.c b/src/btree/bt_sync.c index 412358fed05..64650d6336d 100644 --- a/src/btree/bt_sync.c +++ b/src/btree/bt_sync.c @@ -26,14 +26,12 @@ __sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop) uint64_t internal_bytes, internal_pages, leaf_bytes, leaf_pages; uint64_t oldest_id, saved_snap_min; uint32_t flags; - u_int saved_evict_walk_period; conn = S2C(session); btree = S2BT(session); walk = NULL; txn = &session->txn; saved_snap_min = WT_SESSION_TXN_STATE(session)->snap_min; - saved_evict_walk_period = btree->evict_walk_period; flags = WT_READ_CACHE | WT_READ_NO_GEN; internal_bytes = leaf_bytes = 0; @@ -231,41 +229,9 @@ err: /* On error, clear any left-over tree walk. */ saved_snap_min == WT_TXN_NONE) __wt_txn_release_snapshot(session); - if (btree->checkpointing != WT_CKPT_OFF) { - /* - * Update the checkpoint generation for this handle so visible - * updates newer than the checkpoint can be evicted. - * - * This has to be published before eviction is enabled again, - * so that eviction knows that the checkpoint has completed. - */ - WT_PUBLISH(btree->checkpoint_gen, - conn->txn_global.checkpoint_gen); - WT_STAT_FAST_DATA_SET(session, - btree_checkpoint_generation, btree->checkpoint_gen); - - /* - * Clear the checkpoint flag and push the change; not required, - * but publishing the change means stalled eviction gets moving - * as soon as possible. - */ - btree->checkpointing = WT_CKPT_OFF; - WT_FULL_BARRIER(); - - /* - * In case this tree was being skipped by the eviction server - * during the checkpoint, restore the previous state. - */ - btree->evict_walk_period = saved_evict_walk_period; - - /* - * Wake the eviction server, in case application threads have - * stalled while the eviction server decided it couldn't make - * progress. Without this, application threads will be stalled - * until the eviction server next wakes. - */ - WT_TRET(__wt_evict_server_wake(session)); - } + /* Clear the checkpoint flag and push the change. */ + if (btree->checkpointing != WT_CKPT_OFF) + WT_PUBLISH(btree->checkpointing, WT_CKPT_OFF); __wt_spin_unlock(session, &btree->flush_lock); diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c index 62f6d099d0f..1efb56dccfe 100644 --- a/src/txn/txn_ckpt.c +++ b/src/txn/txn_ckpt.c @@ -1225,7 +1225,43 @@ err: /* static int __checkpoint_tree_helper(WT_SESSION_IMPL *session, const char *cfg[]) { - return (__checkpoint_tree(session, true, cfg)); + WT_BTREE *btree; + WT_CONNECTION_IMPL *conn; + WT_DECL_RET; + u_int saved_evict_walk_period; + + btree = S2BT(session); + conn = S2C(session); + saved_evict_walk_period = btree->evict_walk_period; + + ret = __checkpoint_tree(session, true, cfg); + + /* + * Update the checkpoint generation for this handle so visible + * updates newer than the checkpoint can be evicted. + * + * This has to be published before eviction is enabled again, + * so that eviction knows that the checkpoint has completed. + */ + WT_PUBLISH(btree->checkpoint_gen, conn->txn_global.checkpoint_gen); + WT_STAT_FAST_DATA_SET(session, + btree_checkpoint_generation, btree->checkpoint_gen); + + /* + * In case this tree was being skipped by the eviction server + * during the checkpoint, restore the previous state. + */ + btree->evict_walk_period = saved_evict_walk_period; + + /* + * Wake the eviction server, in case application threads have + * stalled while the eviction server decided it couldn't make + * progress. Without this, application threads will be stalled + * until the eviction server next wakes. + */ + WT_TRET(__wt_evict_server_wake(session)); + + return (ret); } /* |