summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChenhao Qu <chenhao.qu@mongodb.com>2021-10-06 06:50:04 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-06 07:30:19 +0000
commit8ac7a03dd9a3691b356b3eb92967652529d7f1ca (patch)
tree48d4155012acbe964f121a1d9fc05208d1d0a21b
parent437af4d512b729d8a2a6e765eade41bcf5be6f95 (diff)
downloadmongo-8ac7a03dd9a3691b356b3eb92967652529d7f1ca.tar.gz
Import wiredtiger: cbaffc1dda333b1f1908b9a4cfab69bf178a41b9 from branch mongodb-master
ref: 0c90aafd22..cbaffc1dda for: 5.2.0 WT-7392 Added evicted flag to dhandle for use by session sweep
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/btree/bt_read.c1
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_dhandle.c3
-rw-r--r--src/third_party/wiredtiger/src/evict/evict_lru.c9
-rw-r--r--src/third_party/wiredtiger/src/include/dhandle.h11
-rw-r--r--src/third_party/wiredtiger/src/session/session_dhandle.c14
6 files changed, 25 insertions, 15 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 821289e1741..2bebe03d76c 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-master",
- "commit": "0c90aafd226dbf337f294bd4b3beb26060c1109e"
+ "commit": "cbaffc1dda333b1f1908b9a4cfab69bf178a41b9"
}
diff --git a/src/third_party/wiredtiger/src/btree/bt_read.c b/src/third_party/wiredtiger/src/btree/bt_read.c
index 687c21ec086..3d6a8e82215 100644
--- a/src/third_party/wiredtiger/src/btree/bt_read.c
+++ b/src/third_party/wiredtiger/src/btree/bt_read.c
@@ -258,6 +258,7 @@ read:
/* We just read a page, don't evict it before we have a chance to use it. */
evict_skip = true;
+ F_CLR(session->dhandle, WT_DHANDLE_EVICTED);
/*
* If configured to not trash the cache, leave the page generation unset, we'll set it
diff --git a/src/third_party/wiredtiger/src/conn/conn_dhandle.c b/src/third_party/wiredtiger/src/conn/conn_dhandle.c
index decf70dd7e4..215eb5a47f0 100644
--- a/src/third_party/wiredtiger/src/conn/conn_dhandle.c
+++ b/src/third_party/wiredtiger/src/conn/conn_dhandle.c
@@ -319,6 +319,9 @@ __wt_conn_dhandle_close(WT_SESSION_IMPL *session, bool final, bool mark_dead)
/* Reset the tree's eviction priority (if any). */
__wt_evict_priority_clear(session);
+
+ /* Mark the advisory bit that the tree has been evicted. */
+ F_SET(dhandle, WT_DHANDLE_EVICTED);
}
/*
diff --git a/src/third_party/wiredtiger/src/evict/evict_lru.c b/src/third_party/wiredtiger/src/evict/evict_lru.c
index 3e98127a154..0bfaf1c9f33 100644
--- a/src/third_party/wiredtiger/src/evict/evict_lru.c
+++ b/src/third_party/wiredtiger/src/evict/evict_lru.c
@@ -2047,9 +2047,14 @@ fast:
*/
if (pages_queued < target_pages / 2 && !urgent_queued)
btree->evict_walk_period = WT_MIN(WT_MAX(1, 2 * btree->evict_walk_period), 100);
- else if (pages_queued == target_pages)
+ else if (pages_queued == target_pages) {
btree->evict_walk_period = 0;
- else if (btree->evict_walk_period > 0)
+ /*
+ * If there's a chance the Btree was fully evicted, update the evicted flag in the handle.
+ */
+ if (__wt_btree_bytes_evictable(session) == 0)
+ F_SET(session->dhandle, WT_DHANDLE_EVICTED);
+ } else if (btree->evict_walk_period > 0)
btree->evict_walk_period /= 2;
/*
diff --git a/src/third_party/wiredtiger/src/include/dhandle.h b/src/third_party/wiredtiger/src/include/dhandle.h
index 133ab688544..d4e23e52c8f 100644
--- a/src/third_party/wiredtiger/src/include/dhandle.h
+++ b/src/third_party/wiredtiger/src/include/dhandle.h
@@ -119,11 +119,12 @@ struct __wt_data_handle {
#define WT_DHANDLE_DISCARD 0x002u /* Close on release */
#define WT_DHANDLE_DISCARD_KILL 0x004u /* Mark dead on release */
#define WT_DHANDLE_DROPPED 0x008u /* Handle is dropped */
-#define WT_DHANDLE_EXCLUSIVE 0x010u /* Exclusive access */
-#define WT_DHANDLE_HS 0x020u /* History store table */
-#define WT_DHANDLE_IS_METADATA 0x040u /* Metadata handle */
-#define WT_DHANDLE_LOCK_ONLY 0x080u /* Handle only used as a lock */
-#define WT_DHANDLE_OPEN 0x100u /* Handle is open */
+#define WT_DHANDLE_EVICTED 0x010u /* Btree is evicted (advisory) */
+#define WT_DHANDLE_EXCLUSIVE 0x020u /* Exclusive access */
+#define WT_DHANDLE_HS 0x040u /* History store table */
+#define WT_DHANDLE_IS_METADATA 0x080u /* Metadata handle */
+#define WT_DHANDLE_LOCK_ONLY 0x100u /* Handle only used as a lock */
+#define WT_DHANDLE_OPEN 0x200u /* Handle is open */
/* AUTOMATIC FLAG VALUE GENERATION STOP 12 */
uint32_t flags;
diff --git a/src/third_party/wiredtiger/src/session/session_dhandle.c b/src/third_party/wiredtiger/src/session/session_dhandle.c
index 8172fc8841d..685bc6e0c46 100644
--- a/src/third_party/wiredtiger/src/session/session_dhandle.c
+++ b/src/third_party/wiredtiger/src/session/session_dhandle.c
@@ -362,7 +362,6 @@ __session_dhandle_sweep(WT_SESSION_IMPL *session)
WT_DATA_HANDLE *dhandle;
WT_DATA_HANDLE_CACHE *dhandle_cache, *dhandle_cache_tmp;
uint64_t now;
- bool empty_btree;
conn = S2C(session);
@@ -379,15 +378,16 @@ __session_dhandle_sweep(WT_SESSION_IMPL *session)
TAILQ_FOREACH_SAFE(dhandle_cache, &session->dhandles, q, dhandle_cache_tmp)
{
dhandle = dhandle_cache->dhandle;
- empty_btree = false;
- if (WT_DHANDLE_BTREE(dhandle))
- WT_WITH_DHANDLE(
- session, dhandle, empty_btree = (__wt_btree_bytes_evictable(session) == 0));
+ /*
+ * Only discard handles that are dead or dying and, in the case of btrees, have been
+ * evicted. These checks are not done with any locks in place, other than the data handle
+ * reference, so we cannot peer past what is in the dhandle directly.
+ */
if (dhandle != session->dhandle && dhandle->session_inuse == 0 &&
(WT_DHANDLE_INACTIVE(dhandle) ||
- (dhandle->timeofdeath != 0 && now - dhandle->timeofdeath > conn->sweep_idle_time) ||
- empty_btree)) {
+ (dhandle->timeofdeath != 0 && now - dhandle->timeofdeath > conn->sweep_idle_time)) &&
+ (!WT_DHANDLE_BTREE(dhandle) || F_ISSET(dhandle, WT_DHANDLE_EVICTED))) {
WT_STAT_CONN_INCR(session, dh_session_handles);
WT_ASSERT(session, !WT_IS_METADATA(dhandle));
__session_discard_dhandle(session, dhandle_cache);