summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/evict
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2017-03-17 11:02:25 +1100
committerMichael Cahill <michael.cahill@mongodb.com>2017-03-17 11:02:25 +1100
commit5df5125fd63295a9b71d79e68a84ba51e0c1c87f (patch)
treee28bae1a5e7ec42bb236b40caef42bfc5df6089e /src/third_party/wiredtiger/src/evict
parentf53a88a57da5788b355cb3037061372a706ccf0d (diff)
downloadmongo-5df5125fd63295a9b71d79e68a84ba51e0c1c87f.tar.gz
Import wiredtiger: cc2f15f595b16479affd73791c207da334453bcc from branch mongodb-3.6
ref: e1bcc30da9..cc2f15f595 for: 3.5.5 WT-3149 Change eviction to start new walks from a random place in the tree WT-3187 Hang on shutdown with a busy cache pool WT-3188 Fix error handling in logging where fatal errors could lead to a hang WT-3189 Fix a segfault in the eviction server random positioning WT-3206 bug: core dump on NULL page index WT-3218 unexpected checkpoint ordering failures
Diffstat (limited to 'src/third_party/wiredtiger/src/evict')
-rw-r--r--src/third_party/wiredtiger/src/evict/evict_lru.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/third_party/wiredtiger/src/evict/evict_lru.c b/src/third_party/wiredtiger/src/evict/evict_lru.c
index 42fe4d4608e..f1949a7c320 100644
--- a/src/third_party/wiredtiger/src/evict/evict_lru.c
+++ b/src/third_party/wiredtiger/src/evict/evict_lru.c
@@ -1654,31 +1654,33 @@ __evict_walk_file(WT_SESSION_IMPL *session,
!F_ISSET(cache, WT_CACHE_EVICT_CLEAN))
min_pages *= 10;
+ walk_flags =
+ WT_READ_CACHE | WT_READ_NO_EVICT | WT_READ_NO_GEN | WT_READ_NO_WAIT;
+
/*
* Choose a random point in the tree if looking for candidates in a
* tree with no starting point set. This is mostly aimed at ensuring
* eviction fairly visits all pages in trees with a lot of in-cache
* content.
*/
- if (btree->evict_ref == NULL) {
- /* Ensure internal pages indexes remain valid for our walk */
- WT_WITH_PAGE_INDEX(session, ret =
- __wt_random_descent(session, &btree->evict_ref, true));
- WT_RET_NOTFOUND_OK(ret);
-
- /*
- * Reverse the direction of the walk each time we start at a
- * random point so both ends of the tree are equally likely to
- * be visited.
- */
- btree->evict_walk_reverse = !btree->evict_walk_reverse;
- }
-
- walk_flags =
- WT_READ_CACHE | WT_READ_NO_EVICT | WT_READ_NO_GEN | WT_READ_NO_WAIT;
-
- if (btree->evict_walk_reverse)
+ switch (btree->evict_walk_state) {
+ case WT_EVICT_WALK_NEXT:
+ break;
+ case WT_EVICT_WALK_PREV:
FLD_SET(walk_flags, WT_READ_PREV);
+ break;
+ case WT_EVICT_WALK_RAND_PREV:
+ FLD_SET(walk_flags, WT_READ_PREV);
+ /* FALLTHROUGH */
+ case WT_EVICT_WALK_RAND_NEXT:
+ if (btree->evict_ref == NULL) {
+ /* Ensure internal pages indexes remain valid */
+ WT_WITH_PAGE_INDEX(session, ret = __wt_random_descent(
+ session, &btree->evict_ref, true));
+ WT_RET_NOTFOUND_OK(ret);
+ }
+ break;
+ }
/*
* Get some more eviction candidate pages, starting at the last saved
@@ -1713,8 +1715,16 @@ __evict_walk_file(WT_SESSION_IMPL *session,
pages_seen > min_pages &&
(pages_queued == 0 || (pages_seen / pages_queued) >
(min_pages / target_pages));
- if (give_up)
+ if (give_up) {
+ /*
+ * Try a different walk start point next time if a
+ * walk gave up.
+ */
+ btree->evict_walk_state =
+ (btree->evict_walk_state + 1) %
+ WT_EVICT_WALK_MAX_LEGAL_VALUE;
break;
+ }
if (ref == NULL) {
if (++restarts == 2)