Commit ff5a25cc authored by Rich Prohaska's avatar Rich Prohaska

FT-584 use trylock inside of the lock tree manager get_status function so that it is non-blocking

parent 4cb144d9
...@@ -530,32 +530,31 @@ void locktree_manager::get_status(LTM_STATUS statp) { ...@@ -530,32 +530,31 @@ void locktree_manager::get_status(LTM_STATUS statp) {
STATUS_VALUE(LTM_LONG_WAIT_ESCALATION_COUNT) = m_long_wait_escalation_count; STATUS_VALUE(LTM_LONG_WAIT_ESCALATION_COUNT) = m_long_wait_escalation_count;
STATUS_VALUE(LTM_LONG_WAIT_ESCALATION_TIME) = m_long_wait_escalation_time; STATUS_VALUE(LTM_LONG_WAIT_ESCALATION_TIME) = m_long_wait_escalation_time;
mutex_lock();
uint64_t lock_requests_pending = 0; uint64_t lock_requests_pending = 0;
uint64_t sto_num_eligible = 0; uint64_t sto_num_eligible = 0;
uint64_t sto_end_early_count = 0; uint64_t sto_end_early_count = 0;
tokutime_t sto_end_early_time = 0; tokutime_t sto_end_early_time = 0;
size_t num_locktrees = 0;
struct lt_counters lt_counters = {};
struct lt_counters lt_counters = m_lt_counters; if (toku_mutex_trylock(&m_mutex) == 0) {
lt_counters = m_lt_counters;
size_t num_locktrees = m_locktree_map.size(); num_locktrees = m_locktree_map.size();
for (size_t i = 0; i < num_locktrees; i++) { for (size_t i = 0; i < num_locktrees; i++) {
locktree *lt; locktree *lt;
int r = m_locktree_map.fetch(i, &lt); int r = m_locktree_map.fetch(i, &lt);
invariant_zero(r); invariant_zero(r);
if (toku_mutex_trylock(&lt->m_lock_request_info.mutex) == 0) {
toku_mutex_lock(&lt->m_lock_request_info.mutex);
lock_requests_pending += lt->m_lock_request_info.pending_lock_requests.size(); lock_requests_pending += lt->m_lock_request_info.pending_lock_requests.size();
lt_counters.add(lt->get_lock_request_info()->counters); lt_counters.add(lt->get_lock_request_info()->counters);
toku_mutex_unlock(&lt->m_lock_request_info.mutex); toku_mutex_unlock(&lt->m_lock_request_info.mutex);
}
sto_num_eligible += lt->sto_txnid_is_valid_unsafe() ? 1 : 0; sto_num_eligible += lt->sto_txnid_is_valid_unsafe() ? 1 : 0;
sto_end_early_count += lt->m_sto_end_early_count; sto_end_early_count += lt->m_sto_end_early_count;
sto_end_early_time += lt->m_sto_end_early_time; sto_end_early_time += lt->m_sto_end_early_time;
} }
mutex_unlock(); mutex_unlock();
}
STATUS_VALUE(LTM_NUM_LOCKTREES) = num_locktrees; STATUS_VALUE(LTM_NUM_LOCKTREES) = num_locktrees;
STATUS_VALUE(LTM_LOCK_REQUESTS_PENDING) = lock_requests_pending; STATUS_VALUE(LTM_LOCK_REQUESTS_PENDING) = lock_requests_pending;
......
...@@ -212,6 +212,21 @@ toku_mutex_lock(toku_mutex_t *mutex) { ...@@ -212,6 +212,21 @@ toku_mutex_lock(toku_mutex_t *mutex) {
#endif #endif
} }
static inline int
toku_mutex_trylock(toku_mutex_t *mutex) {
int r = pthread_mutex_trylock(&mutex->pmutex);
#if TOKU_PTHREAD_DEBUG
if (r == 0) {
invariant(mutex->valid);
invariant(!mutex->locked);
invariant(mutex->owner == 0);
mutex->locked = true;
mutex->owner = pthread_self();
}
#endif
return r;
}
static inline void static inline void
toku_mutex_unlock(toku_mutex_t *mutex) { toku_mutex_unlock(toku_mutex_t *mutex) {
#if TOKU_PTHREAD_DEBUG #if TOKU_PTHREAD_DEBUG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment