Commit 788b3ee8 authored by Marko Mäkelä's avatar Marko Mäkelä

Reduce the diff from 5.7 in DeadlockChecker::search()

This is a non-functional change.
parent bd7ed1b9
...@@ -306,7 +306,7 @@ class DeadlockChecker { ...@@ -306,7 +306,7 @@ class DeadlockChecker {
static state_t s_states[MAX_STACK_SIZE]; static state_t s_states[MAX_STACK_SIZE];
/** Set if thd_rpl_deadlock_check() should be called for waits. */ /** Set if thd_rpl_deadlock_check() should be called for waits. */
bool m_report_waiters; const bool m_report_waiters;
}; };
/** Counter to mark visited nodes during deadlock search. */ /** Counter to mark visited nodes during deadlock search. */
...@@ -7611,7 +7611,6 @@ DeadlockChecker::search() ...@@ -7611,7 +7611,6 @@ DeadlockChecker::search()
const lock_t* lock = get_first_lock(&heap_no); const lock_t* lock = get_first_lock(&heap_no);
for (;;) { for (;;) {
/* We should never visit the same sub-tree more than once. */ /* We should never visit the same sub-tree more than once. */
ut_ad(lock == NULL || !is_visited(lock)); ut_ad(lock == NULL || !is_visited(lock));
...@@ -7626,7 +7625,9 @@ DeadlockChecker::search() ...@@ -7626,7 +7625,9 @@ DeadlockChecker::search()
if (lock == NULL) { if (lock == NULL) {
break; break;
} else if (lock == m_wait_lock) { }
if (lock == m_wait_lock) {
/* We can mark this subtree as searched */ /* We can mark this subtree as searched */
ut_ad(lock->trx->lock.deadlock_mark <= m_mark_start); ut_ad(lock->trx->lock.deadlock_mark <= m_mark_start);
...@@ -7641,40 +7642,39 @@ DeadlockChecker::search() ...@@ -7641,40 +7642,39 @@ DeadlockChecker::search()
/* Backtrack */ /* Backtrack */
lock = NULL; lock = NULL;
continue;
}
} else if (!lock_has_to_wait(m_wait_lock, lock)) { if (!lock_has_to_wait(m_wait_lock, lock)) {
/* No conflict, next lock */ /* No conflict, next lock */
lock = get_next_lock(lock, heap_no); lock = get_next_lock(lock, heap_no);
continue;
}
} else if (lock->trx == m_start) { if (lock->trx == m_start) {
/* Found a cycle. */ /* Found a cycle. */
notify(lock); notify(lock);
return select_victim();
}
return(select_victim()); if (is_too_deep()) {
} else if (is_too_deep()) {
/* Search too deep to continue. */ /* Search too deep to continue. */
m_too_deep = true; m_too_deep = true;
return(m_start); return m_start;
}
} else {
/* We do not need to report autoinc locks to the upper /* We do not need to report autoinc locks to the upper
layer. These locks are released before commit, so they layer. These locks are released before commit, so they
can not cause deadlocks with binlog-fixed commit can not cause deadlocks with binlog-fixed commit
order. */ order. */
if (m_report_waiters && if (m_report_waiters
(lock_get_type_low(lock) != LOCK_TABLE || && (lock_get_type_low(lock) != LOCK_TABLE
lock_get_mode(lock) != LOCK_AUTO_INC)) { || lock_get_mode(lock) != LOCK_AUTO_INC)) {
thd_rpl_deadlock_check(m_start->mysql_thd, thd_rpl_deadlock_check(m_start->mysql_thd,
lock->trx->mysql_thd); lock->trx->mysql_thd);
} }
if (lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) { if (lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) {
/* Another trx ahead has requested a lock in an /* Another trx ahead has requested a lock in an
incompatible mode, and is itself waiting for a lock. */ incompatible mode, and is itself waiting for a lock. */
...@@ -7682,10 +7682,9 @@ DeadlockChecker::search() ...@@ -7682,10 +7682,9 @@ DeadlockChecker::search()
if (!push(lock, heap_no)) { if (!push(lock, heap_no)) {
m_too_deep = true; m_too_deep = true;
return(m_start); return m_start;
} }
m_wait_lock = lock->trx->lock.wait_lock; m_wait_lock = lock->trx->lock.wait_lock;
lock = get_first_lock(&heap_no); lock = get_first_lock(&heap_no);
...@@ -7693,12 +7692,10 @@ DeadlockChecker::search() ...@@ -7693,12 +7692,10 @@ DeadlockChecker::search()
if (is_visited(lock)) { if (is_visited(lock)) {
lock = get_next_lock(lock, heap_no); lock = get_next_lock(lock, heap_no);
} }
} else { } else {
lock = get_next_lock(lock, heap_no); lock = get_next_lock(lock, heap_no);
} }
} }
}
ut_a(lock == NULL && m_n_elems == 0); ut_a(lock == NULL && m_n_elems == 0);
...@@ -7783,17 +7780,13 @@ DeadlockChecker::check_and_resolve(const lock_t* lock, trx_t* trx) ...@@ -7783,17 +7780,13 @@ DeadlockChecker::check_and_resolve(const lock_t* lock, trx_t* trx)
trx_mutex_exit(trx); trx_mutex_exit(trx);
const trx_t* victim_trx; const trx_t* victim_trx;
THD* start_mysql_thd; const bool report_waiters = trx->mysql_thd
bool report_waits = false; && thd_need_wait_reports(trx->mysql_thd);
start_mysql_thd = trx->mysql_thd;
if (start_mysql_thd && thd_need_wait_reports(start_mysql_thd))
report_waits = true;
/* Try and resolve as many deadlocks as possible. */ /* Try and resolve as many deadlocks as possible. */
do { do {
DeadlockChecker checker(trx, lock, s_lock_mark_counter, report_waits); DeadlockChecker checker(trx, lock, s_lock_mark_counter,
report_waiters);
victim_trx = checker.search(); victim_trx = checker.search();
......
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