diff options
author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2016-02-25 10:19:23 +1100 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2016-02-25 10:19:23 +1100 |
commit | 82a443ff9fec5047b1c3672b68c7c445fe4506c5 (patch) | |
tree | 56586822dfd5858c543fd308b0a85047ead78ee7 | |
parent | 749a9fb339c0ff46bacd02876e1b90c541fd0f7b (diff) | |
parent | 470ef1c6c94b8cf56a47841f5669e760b68c1bb9 (diff) | |
download | mongo-82a443ff9fec5047b1c3672b68c7c445fe4506c5.tar.gz |
Merge pull request #2364 from wiredtiger/WT-2264
WT-2264 Don't have write leaves chase inserts indefinitely,
-rw-r--r-- | src/btree/bt_sync.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/btree/bt_sync.c b/src/btree/bt_sync.c index bbfb06c636f..5273f0ee2c3 100644 --- a/src/btree/bt_sync.c +++ b/src/btree/bt_sync.c @@ -23,12 +23,11 @@ __sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop) WT_REF *walk; WT_TXN *txn; uint64_t internal_bytes, internal_pages, leaf_bytes, leaf_pages; - uint64_t saved_snap_min; + uint64_t oldest_id, saved_snap_min; uint32_t flags; bool evict_reset; btree = S2BT(session); - walk = NULL; txn = &session->txn; saved_snap_min = WT_SESSION_TXN_STATE(session)->snap_min; @@ -56,6 +55,15 @@ __sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop) return (0); } + /* + * Save the oldest transaction ID we need to keep around. + * Otherwise, in a busy system, we could be updating pages so + * fast that write leaves never catches up. We deliberately + * have no transaction running at this point that would keep + * the oldest ID from moving forwards as we walk the tree. + */ + oldest_id = __wt_txn_oldest_id(session); + flags |= WT_READ_NO_WAIT | WT_READ_SKIP_INTL; for (walk = NULL;;) { WT_ERR(__wt_tree_walk(session, &walk, flags)); @@ -64,13 +72,13 @@ __sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop) /* * Write dirty pages if nobody beat us to it. Don't - * try to write the hottest pages: checkpoint will have - * to visit them anyway. + * try to write hot pages (defined as pages that have + * been updated since the write phase leaves started): + * checkpoint will have to visit them anyway. */ page = walk->page; if (__wt_page_is_modified(page) && - __wt_txn_visible_all( - session, page->modify->update_txn)) { + WT_TXNID_LT(page->modify->update_txn, oldest_id)) { if (txn->isolation == WT_ISO_READ_COMMITTED) __wt_txn_get_snapshot(session); leaf_bytes += page->memory_footprint; |