diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-11-05 13:56:20 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-11-05 13:56:20 +0200 |
commit | 093e2e4f7b87306f540ecffcd8a27db010c1ed25 (patch) | |
tree | cb32020d99535c57ca9c152b6b4328b3fcae64b5 | |
parent | 4b9e6f4896ee25b21820704366375ed64e4ccfa2 (diff) | |
download | mariadb-git-bb-10.2-midenok-innodb.tar.gz |
Revert "MDEV-18706 InnoDB locking code debug helpers"bb-10.2-midenok-innodb
This reverts commit b8de354823769a9c01d0b538221032111ba20ba7.
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 1 | ||||
-rw-r--r-- | storage/innobase/include/lock0lock.h | 24 | ||||
-rw-r--r-- | storage/innobase/include/lock0priv.h | 73 | ||||
-rw-r--r-- | storage/innobase/include/lock0priv.ic | 14 | ||||
-rw-r--r-- | storage/innobase/include/lock0types.h | 158 | ||||
-rw-r--r-- | storage/innobase/lock/lock0lock.cc | 29 | ||||
-rw-r--r-- | storage/innobase/lock/lock0wait.cc | 2 | ||||
-rw-r--r-- | storage/innobase/ut/ut0ut.cc | 35 |
8 files changed, 80 insertions, 256 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 4c4c3134ad3..0617005a213 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -19684,7 +19684,6 @@ wsrep_innobase_kill_one_trx( if (wait_lock) { WSREP_DEBUG("canceling wait lock"); - DBUG_LOG("ib_lock", VICTIM(victim_trx) << *wait_lock); victim_trx->lock.was_chosen_as_deadlock_victim= TRUE; lock_cancel_waiting_and_release(wait_lock); } diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index 8dfcacdfd1c..edde6bf516e 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -1050,28 +1050,4 @@ lock_get_info( #include "lock0lock.ic" -/** The global output operator is overloaded to conveniently -print the lock_table_t object into the given output stream. -@param[in,out] out the output stream -@param[in] lock the table lock -@return the given output stream */ -inline -std::ostream& -operator<<(std::ostream& out, const lock_table_t& lock) -{ - return(lock.print(out)); -} - -/** The global output operator is overloaded to conveniently -print the ib_lock_t object into the given output stream. -@param[in,out] out the output stream -@param[in] lock the record lock -@return the given output stream */ -inline -std::ostream& -operator<<(std::ostream& out, const ib_lock_t& lock) -{ - return(lock.print(out)); -} - #endif diff --git a/storage/innobase/include/lock0priv.h b/storage/innobase/include/lock0priv.h index 62873d60ffb..470eed9a6db 100644 --- a/storage/innobase/include/lock0priv.h +++ b/storage/innobase/include/lock0priv.h @@ -48,21 +48,56 @@ those functions in lock/ */ inline std::ostream& lock_table_t::print(std::ostream& out) const { - out << "[" << table->name.m_name << "]"; + out << "[lock_table_t: name=" << table->name << "]"; return(out); } +/** The global output operator is overloaded to conveniently +print the lock_table_t object into the given output stream. +@param[in,out] out the output stream +@param[in] lock the table lock +@return the given output stream */ inline std::ostream& -ib_lock_t::print(std::ostream& out) const +operator<<(std::ostream& out, const lock_table_t& lock) { - out << "[trx=" << trx << "(" << trx->lock.trx_locks.count - << ":" << trx->lock.table_locks.size() << "), "; - if (index) { - out << "index=" << index << "(" - << (index->is_primary() ? "#" : index->name()) << "), "; + return(lock.print(out)); +} + +/** Convert the member 'type_mode' into a human readable string. +@return human readable string */ +inline +std::string +ib_lock_t::type_mode_string() const +{ + std::ostringstream sout; + sout << type_string(); + sout << " | " << lock_mode_string(mode()); + + if (is_record_not_gap()) { + sout << " | LOCK_REC_NOT_GAP"; + } + + if (is_waiting()) { + sout << " | LOCK_WAIT"; } - out << "type_mode=" << type_mode << "=" << type_mode_string() << " "; + + if (is_gap()) { + sout << " | LOCK_GAP"; + } + + if (is_insert_intention()) { + sout << " | LOCK_INSERT_INTENTION"; + } + return(sout.str()); +} + +inline +std::ostream& +ib_lock_t::print(std::ostream& out) const +{ + out << "[lock_t: type_mode=" << type_mode << "(" + << type_mode_string() << ")"; if (is_record_lock()) { out << un_member.rec_lock; @@ -74,6 +109,17 @@ ib_lock_t::print(std::ostream& out) const return(out); } +inline +std::ostream& +operator<<(std::ostream& out, const ib_lock_t& lock) +{ + return(lock.print(out)); +} + +#ifdef UNIV_DEBUG +extern ibool lock_print_waits; +#endif /* UNIV_DEBUG */ + /** Restricts the length of search we will do in the waits-for graph of transactions */ static const ulint LOCK_MAX_N_STEPS_IN_DEADLOCK_CHECK = 1000000; @@ -549,15 +595,6 @@ lock_rec_get_first( ulint heap_no);/*!< in: heap number of the record */ /*********************************************************************//** -Gets the mode from type_mode. -@return mode */ -UNIV_INLINE -enum lock_mode -lock_get_mode( -/*==========*/ - const ib_uint32_t type_mode); - -/*********************************************************************//** Gets the mode of a lock. @return mode */ UNIV_INLINE @@ -634,7 +671,6 @@ inline void lock_set_lock_and_trx_wait(lock_t* lock, trx_t* trx) trx->lock.wait_lock = lock; lock->type_mode |= LOCK_WAIT; - DBUG_LOG("ib_lock", "+WAIT("<< lock << ") " << *lock); } /** Reset the wait status of a lock. @@ -647,7 +683,6 @@ inline void lock_reset_lock_and_trx_wait(lock_t* lock) || lock->trx->lock.wait_lock == lock); lock->trx->lock.wait_lock = NULL; lock->type_mode &= ~LOCK_WAIT; - DBUG_LOG("ib_lock", "-WAIT("<< lock << ") " << *lock); } inline diff --git a/storage/innobase/include/lock0priv.ic b/storage/innobase/include/lock0priv.ic index 0884058b429..8bb145e41fc 100644 --- a/storage/innobase/include/lock0priv.ic +++ b/storage/innobase/include/lock0priv.ic @@ -287,18 +287,6 @@ lock_rec_get_next_on_page_const( } /*********************************************************************//** -Gets the mode from type_mode. -@return mode */ -UNIV_INLINE -enum lock_mode -lock_get_mode( -/*==========*/ - const ib_uint32_t type_mode) -{ - return(static_cast<enum lock_mode>(type_mode & LOCK_MODE_MASK)); -} - -/*********************************************************************//** Gets the mode of a lock. @return mode */ UNIV_INLINE @@ -309,7 +297,7 @@ lock_get_mode( { ut_ad(lock); - return(lock_get_mode(lock->type_mode)); + return(static_cast<enum lock_mode>(lock->type_mode & LOCK_MODE_MASK)); } /*********************************************************************//** diff --git a/storage/innobase/include/lock0types.h b/storage/innobase/include/lock0types.h index ea93fb97894..35af8eb4a80 100644 --- a/storage/innobase/include/lock0types.h +++ b/storage/innobase/include/lock0types.h @@ -57,19 +57,19 @@ const char* lock_mode_string(enum lock_mode mode) { switch (mode) { case LOCK_IS: - return("IS"); + return("LOCK_IS"); case LOCK_IX: - return("IX"); + return("LOCK_IX"); case LOCK_S: - return("S"); + return("LOCK_S"); case LOCK_X: - return("X"); + return("LOCK_X"); case LOCK_AUTO_INC: - return("AUTO_INC"); + return("LOCK_AUTO_INC"); case LOCK_NONE: - return("NONE"); + return("LOCK_NONE"); case LOCK_NONE_UNSET: - return("NONE_UNSET"); + return("LOCK_NONE_UNSET"); default: ut_error; } @@ -109,7 +109,7 @@ struct lock_rec_t { inline std::ostream& lock_rec_t::print(std::ostream& out) const { - out << "[space=" << space << ", page_no=" << page_no + out << "[lock_rec_t: space=" << space << ", page_no=" << page_no << ", n_bits=" << n_bits << "]"; return(out); } @@ -176,51 +176,6 @@ operator<<(std::ostream& out, const lock_rec_t& lock) #endif /* @} */ -inline -const char* -type_string(ulint type_mode) -{ - switch (type_mode & LOCK_TYPE_MASK) { - case LOCK_REC: - return("REC"); - case LOCK_TABLE: - return("TABLE"); - default: - ut_error; - } -} - -/** Convert 'type_mode' into a human readable string. -@return human readable string */ -inline -std::string -type_mode_string(ulint type_mode) -{ - std::ostringstream sout; - lock_mode mode = static_cast<enum lock_mode>(type_mode & LOCK_MODE_MASK); - if (type_mode & LOCK_TYPE_MASK) { - sout << type_string(type_mode) << "|"; - } - sout << lock_mode_string(mode); - - if (type_mode & LOCK_REC_NOT_GAP) { - sout << "|REC_NOT_GAP"; - } - - if (type_mode & LOCK_WAIT) { - sout << "|WAIT"; - } - - if (type_mode & LOCK_GAP) { - sout << "|GAP"; - } - - if (type_mode & LOCK_INSERT_INTENTION) { - sout << "|INSERT_INTENTION"; - } - return(sout.str()); -} - /** Lock struct; protected by lock_sys->mutex */ struct ib_lock_t { @@ -299,98 +254,23 @@ struct ib_lock_t @return the given output stream. */ std::ostream& print(std::ostream& out) const; - std::string type_mode_string() const - { - return ::type_mode_string(type_mode); - } + /** Convert the member 'type_mode' into a human readable string. + @return human readable string */ + std::string type_mode_string() const; const char* type_string() const { - return ::type_string(type_mode); + switch (type_mode & LOCK_TYPE_MASK) { + case LOCK_REC: + return("LOCK_REC"); + case LOCK_TABLE: + return("LOCK_TABLE"); + default: + ut_error; + } } }; typedef UT_LIST_BASE_NODE_T(ib_lock_t) trx_lock_list_t; -#ifndef DBUG_OFF -/* Classes used to catch various locking situations in code */ - -struct ADD /* add lock */ -{ - const lock_t *lock; - ADD(const lock_t *l) : lock(l) - { - } -}; - -inline -std::ostream& -operator<<(std::ostream& out, const ADD& a) -{ - out << "ADD(" << a.lock << ") "; - return out; -} - -struct VICTIM /* deadlock victim */ -{ - const trx_t *trx; - bool set; - VICTIM(const trx_t *t, bool s = true) : trx(t), set(s) - { - } -}; - -inline -std::ostream& -operator<<(std::ostream& out, const VICTIM& v) -{ - out << (v.set ? '+' : '-') << "VICTIM(trx=" << v.trx << ") "; - return out; -} - -struct WEAKER /* precise_mode is weaker than existing lock (of same trx) */ -{ - ulint precise_mode; - lock_t *lock; - WEAKER(ulint m, lock_t *l) : precise_mode(m), lock(l) - { - } -}; - -inline -std::ostream& -operator<<(std::ostream& out, const WEAKER& w) -{ - out << "WEAKER(" << type_mode_string(w.precise_mode) << ", " << w.lock << ") "; - w.lock->print(out); - out << " "; - return out; -} - -struct CONFLICTS /* precise_mode conflicts (or doesn't) with any existing locks */ -{ - const trx_t *trx; - ulint precise_mode; - const lock_t *conflict; - CONFLICTS(const trx_t *t, ulint m, const lock_t *c) : - trx(t), precise_mode(m), conflict(c) - { - } -}; - -inline -std::ostream& -operator<<(std::ostream& out, const CONFLICTS& c) -{ - out << (c.conflict ? "CONFLICTS(trx=" : "NO_CONFLICTS(trx=") - << c.trx << ", " << type_mode_string(c.precise_mode) << ", " - << c.conflict << ") "; - if (c.conflict) { - c.conflict->print(out); - out << " "; - } - return out; -} - -#endif /* !DBUG_OFF */ #endif /* lock0types_h */ diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index ae22d2046ff..45c964c7309 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1004,7 +1004,6 @@ lock_rec_has_expl( { lock_t* lock; - DBUG_ENTER("lock_rec_has_expl"); ut_ad(lock_mutex_own()); ut_ad((precise_mode & LOCK_MODE_MASK) == LOCK_S || (precise_mode & LOCK_MODE_MASK) == LOCK_X); @@ -1016,12 +1015,11 @@ lock_rec_has_expl( if (lock->is_stronger(precise_mode, heap_no, trx)) { - DBUG_LOG("ib_lock", WEAKER(precise_mode, lock)); - DBUG_RETURN(lock); + return(lock); } } - DBUG_RETURN(NULL); + return(NULL); } #ifdef UNIV_DEBUG @@ -1156,7 +1154,6 @@ lock_rec_other_has_conflicting( lock_t* conflict = NULL; bool skip_waiting = false; - DBUG_ENTER("lock_rec_other_has_conflicting"); ut_ad(lock_mutex_own()); bool is_supremum = (heap_no == PAGE_HEAP_NO_SUPREMUM); @@ -1172,10 +1169,7 @@ lock_rec_other_has_conflicting( /* If current trx already acquired a lock not weaker covering same types then we don't have to wait for any locks. */ if (lock->is_stronger(mode, heap_no, trx)) { - - DBUG_LOG("ib_lock", CONFLICTS(trx, mode, NULL) - << "because: " << WEAKER(mode, lock)) ; - DBUG_RETURN(NULL); + return NULL; } else if (lock->trx == trx && !lock->is_waiting()) { if (conflict && conflict->is_waiting()) { conflict = NULL; @@ -1203,8 +1197,7 @@ lock_rec_other_has_conflicting( } #endif /* WITH_WSREP */ - DBUG_LOG("ib_lock", CONFLICTS(trx, mode, conflict)); - DBUG_RETURN(conflict); + return conflict; } /*********************************************************************//** @@ -1480,7 +1473,6 @@ lock_rec_create_low( lock->un_member.rec_lock.n_bits = 8; } lock_rec_bitmap_reset(lock); - DBUG_LOG("ib_lock", ADD(lock) << *lock); lock_rec_set_nth_bit(lock, heap_no); index->table->n_rec_locks++; ut_ad(index->table->get_ref_count() > 0 || !index->table->can_be_evicted); @@ -1509,7 +1501,7 @@ lock_rec_create_low( */ trx_mutex_enter(c_lock->trx); if (c_lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) { - DBUG_LOG("ib_lock", VICTIM(c_lock->trx) << *c_lock); + c_lock->trx->lock.was_chosen_as_deadlock_victim = TRUE; if (UNIV_UNLIKELY(wsrep_debug)) { @@ -3657,7 +3649,6 @@ lock_table_create( trx_mutex_enter(c_lock->trx); if (c_lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) { - DBUG_LOG("ib_lock", VICTIM(c_lock->trx) << *c_lock); c_lock->trx->lock.was_chosen_as_deadlock_victim = TRUE; if (UNIV_UNLIKELY(wsrep_debug)) { @@ -3684,7 +3675,6 @@ lock_table_create( lock_set_lock_and_trx_wait(lock, trx); } - DBUG_LOG("ib_lock", ADD(lock) << *lock); lock->trx->lock.table_locks.push_back(lock); MONITOR_INC(MONITOR_TABLELOCK_CREATED); @@ -3820,8 +3810,6 @@ lock_table_remove_low( UT_LIST_REMOVE(trx->lock.trx_locks, lock); ut_list_remove(table->locks, lock, TableLockGetNode()); - DBUG_LOG("ib_lock", "DEL("<< lock << ") " << *lock); - MONITOR_INC(MONITOR_TABLELOCK_REMOVED); MONITOR_DEC(MONITOR_NUM_TABLELOCK); } @@ -3867,8 +3855,7 @@ lock_table_enqueue_waiting( } #ifdef WITH_WSREP - if (trx->lock.was_chosen_as_deadlock_victim && trx->is_wsrep()) { - DBUG_LOG("ib_lock", "DEADLOCK(" << trx << ") "); + if (trx->is_wsrep() && trx->lock.was_chosen_as_deadlock_victim) { return(DB_DEADLOCK); } #endif /* WITH_WSREP */ @@ -3891,7 +3878,6 @@ lock_table_enqueue_waiting( lock_table_remove_low(lock); lock_reset_lock_and_trx_wait(lock); - DBUG_LOG("ib_lock", "DEADLOCK(" << trx << ") "); return(DB_DEADLOCK); } else if (trx->lock.wait_lock == NULL) { @@ -3904,7 +3890,6 @@ lock_table_enqueue_waiting( trx->lock.que_state = TRX_QUE_LOCK_WAIT; trx->lock.wait_started = time(NULL); - DBUG_LOG("ib_lock", VICTIM(trx, false)); trx->lock.was_chosen_as_deadlock_victim = false; ut_a(que_thr_stop(thr)); @@ -5786,7 +5771,6 @@ lock_rec_convert_impl_to_expl_for_trx( if (!trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY) && !lock_rec_has_expl(LOCK_X | LOCK_REC_NOT_GAP, block, heap_no, trx)) { - DBUG_LOG("ib_lock", "IMPL_TO_EXPL(trx=" << trx << ")"); lock_rec_add_to_queue(LOCK_REC | LOCK_X | LOCK_REC_NOT_GAP, block, heap_no, index, trx, true); } @@ -7207,7 +7191,6 @@ DeadlockChecker::trx_rollback() trx_mutex_enter(trx); - DBUG_LOG("ib_lock", VICTIM(trx)); trx->lock.was_chosen_as_deadlock_victim = true; lock_cancel_waiting_and_release(trx->lock.wait_lock); diff --git a/storage/innobase/lock/lock0wait.cc b/storage/innobase/lock/lock0wait.cc index 79b4e5a58f3..5d0d41ef494 100644 --- a/storage/innobase/lock/lock0wait.cc +++ b/storage/innobase/lock/lock0wait.cc @@ -262,7 +262,6 @@ lock_wait_suspend_thread( if (trx->lock.was_chosen_as_deadlock_victim) { trx->error_state = DB_DEADLOCK; - DBUG_LOG("ib_lock", "DEADLOCK(" << trx << ") "); trx->lock.was_chosen_as_deadlock_victim = false; } @@ -442,7 +441,6 @@ lock_wait_release_thread_if_suspended( if (trx->lock.was_chosen_as_deadlock_victim) { trx->error_state = DB_DEADLOCK; - DBUG_LOG("ib_lock", "DEADLOCK(" << trx << ") "); trx->lock.was_chosen_as_deadlock_victim = false; } diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index f6205f34c1b..1b3d100f9ee 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -673,39 +673,4 @@ fatal_or_error::~fatal_or_error() } // namespace ib -#ifndef DBUG_OFF -static std::string dbug_str; - -template <class T> -const char * dbug_print(T &obj) -{ - std::ostringstream os; - os.str(""); - os.clear(); - obj.print(os); - dbug_str = os.str(); - return dbug_str.c_str(); -} - -const char * dbug_print(ib_lock_t *obj) -{ - return dbug_print(*obj); -} - -const char * dbug_print(lock_rec_t *obj) -{ - return dbug_print(*obj); -} - -const char * dbug_print(lock_table_t *obj) -{ - return dbug_print(*obj); -} - -const char * dbug_print_lock_mode(ib_uint32_t type_mode) -{ - dbug_str = type_mode_string(type_mode); - return dbug_str.c_str(); -} -#endif /* !DBUG_OFF */ #endif /* !UNIV_INNOCHECKSUM */ |