Skip to content

Commit

Permalink
Merge pull request #2586 from wiredtiger/wt-2476
Browse files Browse the repository at this point in the history
WT-2476 - Revert changing the cache evict_walk_lock to the btree evict_lock
  • Loading branch information
agorrod committed Mar 16, 2016
2 parents fcefc12 + 0d2fad0 commit 4ec307d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/btree/bt_handle.c
Expand Up @@ -164,7 +164,6 @@ __wt_btree_close(WT_SESSION_IMPL *session)

/* Destroy locks. */
WT_TRET(__wt_rwlock_destroy(session, &btree->ovfl_lock));
__wt_spin_destroy(session, &btree->evict_lock);
__wt_spin_destroy(session, &btree->flush_lock);

/* Free allocated memory. */
Expand Down Expand Up @@ -351,7 +350,6 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt)
/* Initialize locks. */
WT_RET(__wt_rwlock_alloc(
session, &btree->ovfl_lock, "btree overflow lock"));
WT_RET(__wt_spin_init(session, &btree->evict_lock, "btree evict"));
WT_RET(__wt_spin_init(session, &btree->flush_lock, "btree flush"));

btree->checkpointing = WT_CKPT_OFF; /* Not checkpointing */
Expand Down
2 changes: 2 additions & 0 deletions src/conn/conn_cache.c
Expand Up @@ -158,6 +158,7 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[])
WT_ERR(__wt_cond_alloc(session,
"eviction waiters", false, &cache->evict_waiter_cond));
WT_ERR(__wt_spin_init(session, &cache->evict_lock, "cache eviction"));
WT_ERR(__wt_spin_init(session, &cache->evict_walk_lock, "cache walk"));

/* Allocate the LRU eviction queue. */
cache->evict_slots = WT_EVICT_WALK_BASE + WT_EVICT_WALK_INCR;
Expand Down Expand Up @@ -254,6 +255,7 @@ __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_lock);
__wt_spin_destroy(session, &cache->evict_walk_lock);

__wt_free(session, cache->evict_queue);
__wt_free(session, conn->cache);
Expand Down
16 changes: 9 additions & 7 deletions src/evict/evict_lru.c
Expand Up @@ -796,11 +796,11 @@ __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session)
* The no-eviction flag can be set permanently, in which case we never
* increment the no-eviction count.
*/
__wt_spin_lock(session, &btree->evict_lock);
__wt_spin_lock(session, &cache->evict_walk_lock);
if (F_ISSET(btree, WT_BTREE_NO_EVICTION)) {
if (btree->evict_disabled != 0)
++btree->evict_disabled;
__wt_spin_unlock(session, &btree->evict_lock);
__wt_spin_unlock(session, &cache->evict_walk_lock);
return (0);
}
++btree->evict_disabled;
Expand Down Expand Up @@ -837,7 +837,7 @@ __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session)
err: --btree->evict_disabled;
F_CLR(btree, WT_BTREE_NO_EVICTION);
}
__wt_spin_unlock(session, &btree->evict_lock);
__wt_spin_unlock(session, &cache->evict_walk_lock);
return (ret);
}

Expand All @@ -849,8 +849,10 @@ void
__wt_evict_file_exclusive_off(WT_SESSION_IMPL *session)
{
WT_BTREE *btree;
WT_CACHE *cache;

btree = S2BT(session);
cache = S2C(session)->cache;

/*
* We have seen subtle bugs with multiple threads racing to turn
Expand All @@ -865,10 +867,10 @@ __wt_evict_file_exclusive_off(WT_SESSION_IMPL *session)
* The no-eviction flag can be set permanently, in which case we never
* increment the no-eviction count.
*/
__wt_spin_lock(session, &btree->evict_lock);
__wt_spin_lock(session, &cache->evict_walk_lock);
if (btree->evict_disabled > 0 && --btree->evict_disabled == 0)
F_CLR(btree, WT_BTREE_NO_EVICTION);
__wt_spin_unlock(session, &btree->evict_lock);
__wt_spin_unlock(session, &cache->evict_walk_lock);
}

/*
Expand Down Expand Up @@ -1174,14 +1176,14 @@ retry: while (slot < max_entries && ret == 0) {
* waiting on this thread to acknowledge that action.
*/
if (!F_ISSET(btree, WT_BTREE_NO_EVICTION) &&
!__wt_spin_trylock(session, &btree->evict_lock)) {
!__wt_spin_trylock(session, &cache->evict_walk_lock)) {
if (!F_ISSET(btree, WT_BTREE_NO_EVICTION)) {
cache->evict_file_next = dhandle;
WT_WITH_DHANDLE(session, dhandle,
ret = __evict_walk_file(session, &slot));
WT_ASSERT(session, session->split_gen == 0);
}
__wt_spin_unlock(session, &btree->evict_lock);
__wt_spin_unlock(session, &cache->evict_walk_lock);
}

/*
Expand Down
1 change: 0 additions & 1 deletion src/include/btree.h
Expand Up @@ -129,7 +129,6 @@ struct __wt_btree {
uint64_t rec_max_txn; /* Maximum txn seen (clean trees) */
uint64_t write_gen; /* Write generation */

WT_SPINLOCK evict_lock; /* Eviction lock */
WT_REF *evict_ref; /* Eviction thread's location */
uint64_t evict_priority; /* Relative priority of cached pages */
u_int evict_walk_period; /* Skip this many LRU walks */
Expand Down
1 change: 1 addition & 0 deletions src/include/cache.h
Expand Up @@ -84,6 +84,7 @@ struct __wt_cache {
*/
WT_CONDVAR *evict_cond; /* Eviction server condition */
WT_SPINLOCK evict_lock; /* Eviction LRU queue */
WT_SPINLOCK evict_walk_lock; /* Eviction walk location */
/* Condition signalled when the eviction server populates the queue */
WT_CONDVAR *evict_waiter_cond;

Expand Down

0 comments on commit 4ec307d

Please sign in to comment.