summaryrefslogtreecommitdiff
path: root/src/conn/conn_cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conn/conn_cache.c')
-rw-r--r--src/conn/conn_cache.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/conn/conn_cache.c b/src/conn/conn_cache.c
index 4d33ac608bb..9f15db5382b 100644
--- a/src/conn/conn_cache.c
+++ b/src/conn/conn_cache.c
@@ -158,9 +158,14 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[])
false, 10000, WT_MILLION, &cache->evict_cond));
WT_ERR(__wt_cond_alloc(session,
"eviction waiters", false, &cache->evict_waiter_cond));
+ WT_ERR(__wt_spin_init(session, &cache->evict_pass_lock, "evict pass"));
WT_ERR(__wt_spin_init(session,
&cache->evict_queue_lock, "cache eviction queue"));
WT_ERR(__wt_spin_init(session, &cache->evict_walk_lock, "cache walk"));
+ if ((ret = __wt_open_internal_session(conn, "evict pass",
+ false, WT_SESSION_NO_DATA_HANDLES, &cache->walk_session)) != 0)
+ WT_ERR_MSG(NULL, ret,
+ "Failed to create session for eviction walks");
/* Allocate the LRU eviction queue. */
cache->evict_slots = WT_EVICT_WALK_BASE + WT_EVICT_WALK_INCR;
@@ -223,6 +228,14 @@ __wt_cache_stats_update(WT_SESSION_IMPL *session)
WT_STAT_SET(
session, stats, cache_bytes_overflow, cache->bytes_overflow);
WT_STAT_SET(session, stats, cache_bytes_leaf, leaf);
+
+ /*
+ * The number of files with active walks ~= number of hazard pointers
+ * in the walk session. Note: reading without locking.
+ */
+ if (conn->evict_session != NULL)
+ WT_STAT_SET(session, stats, cache_eviction_walks_active,
+ conn->evict_session->nhazard);
}
/*
@@ -235,6 +248,7 @@ __wt_cache_destroy(WT_SESSION_IMPL *session)
WT_CACHE *cache;
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
+ WT_SESSION *wt_session;
int i;
conn = S2C(session);
@@ -261,8 +275,12 @@ __wt_cache_destroy(WT_SESSION_IMPL *session)
WT_TRET(__wt_cond_auto_destroy(session, &cache->evict_cond));
WT_TRET(__wt_cond_destroy(session, &cache->evict_waiter_cond));
+ __wt_spin_destroy(session, &cache->evict_pass_lock);
__wt_spin_destroy(session, &cache->evict_queue_lock);
__wt_spin_destroy(session, &cache->evict_walk_lock);
+ wt_session = &cache->walk_session->iface;
+ if (wt_session != NULL)
+ WT_TRET(wt_session->close(wt_session, NULL));
for (i = 0; i < WT_EVICT_QUEUE_MAX; ++i) {
__wt_spin_destroy(session, &cache->evict_queues[i].evict_lock);