From 9be507a869760c6adff119e6ea3be9e0e67135dd Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Wed, 16 Nov 2016 16:49:09 +1100 Subject: WT-3023 Don't treat splits as eviction making progress. (#3151) * We still want to get aggressive and/or "stuck" if all we do is rewrite pages over and over. * Reset the eviction skip count in tiny trees: we may never have enough pages to hit the target. --- dist/flags.py | 1 + src/evict/evict_lru.c | 4 +++- src/evict/evict_page.c | 15 +++++++++++++-- src/include/btree.i | 6 +++++- src/include/flags.h | 37 +++++++++++++++++++------------------ 5 files changed, 41 insertions(+), 22 deletions(-) diff --git a/dist/flags.py b/dist/flags.py index e200f95fba6..676f224cbb6 100644 --- a/dist/flags.py +++ b/dist/flags.py @@ -114,6 +114,7 @@ flags = { 'session' : [ 'SESSION_CAN_WAIT', 'SESSION_INTERNAL', + 'SESSION_IN_SPLIT', 'SESSION_LOCK_NO_WAIT', 'SESSION_LOCKED_CHECKPOINT', 'SESSION_LOCKED_HANDLE_LIST', diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c index dfa3fae48d9..ee30bd4b5b3 100644 --- a/src/evict/evict_lru.c +++ b/src/evict/evict_lru.c @@ -1498,11 +1498,13 @@ fast: /* If the page can't be evicted, give up. */ */ if (give_up) btree->evict_walk_reverse = !btree->evict_walk_reverse; - if (give_up && !urgent_queued) + if (pages_queued == 0 && !urgent_queued) btree->evict_walk_period = WT_MIN( WT_MAX(1, 2 * btree->evict_walk_period), 100); else if (pages_queued == target_pages) btree->evict_walk_period = 0; + else if (btree->evict_walk_period > 0) + btree->evict_walk_period /= 2; /* * If we happen to end up on the root page or a page requiring urgent diff --git a/src/evict/evict_page.c b/src/evict/evict_page.c index 3d1557e027e..b15e1c1f26c 100644 --- a/src/evict/evict_page.c +++ b/src/evict/evict_page.c @@ -163,8 +163,19 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool closing) */ WT_ERR(__evict_page_clean_update( session, ref, tree_dead || closing)); - else - WT_ERR(__evict_page_dirty_update(session, ref, closing)); + else { + /* + * The page is not being completely evicted: instead it is + * being split or replaced. In that case, don't increment the + * count of pages evicted, which we use to decide whether + * eviction is making progress. Repeatedly rewriting the same + * page isn't progress. + */ + F_SET(session, WT_SESSION_IN_SPLIT); + ret = __evict_page_dirty_update(session, ref, closing); + F_CLR(session, WT_SESSION_IN_SPLIT); + WT_ERR(ret); + } if (clean_page) { WT_STAT_CONN_INCR(session, cache_eviction_clean); diff --git a/src/include/btree.i b/src/include/btree.i index 8f44bc4eddd..ad603f3ea53 100644 --- a/src/include/btree.i +++ b/src/include/btree.i @@ -408,7 +408,11 @@ __wt_cache_page_evict(WT_SESSION_IMPL *session, WT_PAGE *page) /* Update pages and bytes evicted. */ (void)__wt_atomic_add64(&cache->bytes_evict, page->memory_footprint); - (void)__wt_atomic_addv64(&cache->pages_evict, 1); + + if (F_ISSET(session, WT_SESSION_IN_SPLIT)) + (void)__wt_atomic_subv64(&cache->pages_inmem, 1); + else + (void)__wt_atomic_addv64(&cache->pages_evict, 1); } /* diff --git a/src/include/flags.h b/src/include/flags.h index b0d167525b2..d4c0b519cb1 100644 --- a/src/include/flags.h +++ b/src/include/flags.h @@ -52,24 +52,25 @@ #define WT_READ_WONT_NEED 0x00001000 #define WT_SESSION_CAN_WAIT 0x00000001 #define WT_SESSION_INTERNAL 0x00000002 -#define WT_SESSION_LOCKED_CHECKPOINT 0x00000004 -#define WT_SESSION_LOCKED_HANDLE_LIST 0x00000008 -#define WT_SESSION_LOCKED_METADATA 0x00000010 -#define WT_SESSION_LOCKED_PASS 0x00000020 -#define WT_SESSION_LOCKED_SCHEMA 0x00000040 -#define WT_SESSION_LOCKED_SLOT 0x00000080 -#define WT_SESSION_LOCKED_TABLE 0x00000100 -#define WT_SESSION_LOCKED_TURTLE 0x00000200 -#define WT_SESSION_LOCK_NO_WAIT 0x00000400 -#define WT_SESSION_LOGGING_INMEM 0x00000800 -#define WT_SESSION_LOOKASIDE_CURSOR 0x00001000 -#define WT_SESSION_NO_CACHE 0x00002000 -#define WT_SESSION_NO_DATA_HANDLES 0x00004000 -#define WT_SESSION_NO_EVICTION 0x00008000 -#define WT_SESSION_NO_LOGGING 0x00010000 -#define WT_SESSION_NO_SCHEMA_LOCK 0x00020000 -#define WT_SESSION_QUIET_CORRUPT_FILE 0x00040000 -#define WT_SESSION_SERVER_ASYNC 0x00080000 +#define WT_SESSION_IN_SPLIT 0x00000004 +#define WT_SESSION_LOCKED_CHECKPOINT 0x00000008 +#define WT_SESSION_LOCKED_HANDLE_LIST 0x00000010 +#define WT_SESSION_LOCKED_METADATA 0x00000020 +#define WT_SESSION_LOCKED_PASS 0x00000040 +#define WT_SESSION_LOCKED_SCHEMA 0x00000080 +#define WT_SESSION_LOCKED_SLOT 0x00000100 +#define WT_SESSION_LOCKED_TABLE 0x00000200 +#define WT_SESSION_LOCKED_TURTLE 0x00000400 +#define WT_SESSION_LOCK_NO_WAIT 0x00000800 +#define WT_SESSION_LOGGING_INMEM 0x00001000 +#define WT_SESSION_LOOKASIDE_CURSOR 0x00002000 +#define WT_SESSION_NO_CACHE 0x00004000 +#define WT_SESSION_NO_DATA_HANDLES 0x00008000 +#define WT_SESSION_NO_EVICTION 0x00010000 +#define WT_SESSION_NO_LOGGING 0x00020000 +#define WT_SESSION_NO_SCHEMA_LOCK 0x00040000 +#define WT_SESSION_QUIET_CORRUPT_FILE 0x00080000 +#define WT_SESSION_SERVER_ASYNC 0x00100000 #define WT_STAT_CLEAR 0x00000001 #define WT_STAT_JSON 0x00000002 #define WT_STAT_ON_CLOSE 0x00000004 -- cgit v1.2.1 From 1ce36af292fd0317021091a0523376b0533ac3bf Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Wed, 16 Nov 2016 16:50:01 +1100 Subject: WT-3024 Fix a hang on close caused by leaving a transaction ID pinned. (#3152) --- src/include/txn.h | 3 +++ src/txn/txn_ckpt.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/include/txn.h b/src/include/txn.h index 774f635d7ba..344275e23d0 100644 --- a/src/include/txn.h +++ b/src/include/txn.h @@ -49,8 +49,11 @@ WT_ASSERT((s), (s)->txn.forced_iso > 0); \ (s)->txn.forced_iso--; \ WT_ASSERT((s), txn_state->id == saved_state.id && \ + (txn_state->metadata_pinned == saved_state.metadata_pinned ||\ + saved_state.metadata_pinned == WT_TXN_NONE) && \ (txn_state->pinned_id == saved_state.pinned_id || \ saved_state.pinned_id == WT_TXN_NONE)); \ + txn_state->metadata_pinned = saved_state.metadata_pinned; \ txn_state->pinned_id = saved_state.pinned_id; \ } while (0) diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c index 698cae23562..802ccd84915 100644 --- a/src/txn/txn_ckpt.c +++ b/src/txn/txn_ckpt.c @@ -701,7 +701,8 @@ __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) * can safely ignore the checkpoint ID (see the visible all check for * details). */ - txn_state->id = txn_state->pinned_id = WT_TXN_NONE; + txn_state->id = txn_state->pinned_id = + txn_state->metadata_pinned = WT_TXN_NONE; __wt_writeunlock(session, txn_global->scan_rwlock); /* -- cgit v1.2.1