summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2020-07-20 18:45:53 +0300
committerAleksey Midenkov <midenok@gmail.com>2021-06-17 14:22:09 +0300
commitbbbec8c288634ef01ddc84d391e80d1b7eb9c1d3 (patch)
tree5b5d0e51c883968475b635d4b5f3e139604e2b4c
parent854c7c187b2f5d71fcd397714e8eea6f9dd2433e (diff)
downloadmariadb-git-bb-10.3-midenok-MDEV-18706.tar.gz
-rw-r--r--storage/innobase/handler/ha_innodb.cc5
-rw-r--r--storage/innobase/include/lock0priv.h55
-rw-r--r--storage/innobase/include/lock0types.h201
-rw-r--r--storage/innobase/lock/lock0lock.cc149
-rw-r--r--storage/innobase/lock/lock0wait.cc8
-rw-r--r--storage/innobase/row/row0sel.cc47
-rw-r--r--storage/innobase/ut/ut0ut.cc36
7 files changed, 244 insertions, 257 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 1bf34e415d7..ca099c958d2 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -18968,8 +18968,9 @@ no_victim:
if (wait_lock) {
WSREP_DEBUG("canceling wait lock");
- DBUG_LOG("ib_lock", VICTIM(victim_trx) << *lock);
- victim_trx->lock.was_chosen_as_deadlock_victim= TRUE;
+ DBUG_LOG("ib_lock", VICTIM(victim_trx)
+ << *lock);
+ victim_trx->lock.was_chosen_as_deadlock_victim= TRUE;
lock_cancel_waiting_and_release(wait_lock);
}
diff --git a/storage/innobase/include/lock0priv.h b/storage/innobase/include/lock0priv.h
index 7675de31eb3..4cfb5f5107c 100644
--- a/storage/innobase/include/lock0priv.h
+++ b/storage/innobase/include/lock0priv.h
@@ -68,12 +68,13 @@ inline
std::ostream&
ib_lock_t::print(std::ostream& out) const
{
- out << "[lock_t: trx=" << trx << " (" << trx->lock.trx_locks.count
- << ":" << trx->lock.table_locks.size() << "), "
- << "type_mode=" << type_mode << "=" << type_mode_string() << " ";
+ out << "[lock_t: trx=" << trx << " (" << trx->lock.trx_locks.count << ":"
+ << trx->lock.table_locks.size() << "), "
+ << "type_mode=" << type_mode << "=" << type_mode_string() << " ";
- if (is_record_lock()) {
- out << un_member.rec_lock;
+ if (is_record_lock())
+ {
+ out << un_member.rec_lock;
} else {
out << un_member.tab_lock;
}
@@ -563,14 +564,13 @@ lock_rec_get_first(
const buf_block_t* block, /*!< in: block containing the record */
ulint heap_no);/*!< in: heap number of the record */
-/*********************************************************************//**
-Gets the mode from type_mode.
-@return mode */
+/*********************************************************************/ /**
+ Gets the mode from type_mode.
+ @return mode */
UNIV_INLINE
-enum lock_mode
-lock_get_mode(
-/*==========*/
- const ib_uint32_t type_mode);
+enum lock_mode lock_get_mode(
+ /*==========*/
+ const ib_uint32_t type_mode);
/*********************************************************************//**
Gets the mode of a lock.
@@ -649,7 +649,7 @@ 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);
+ DBUG_LOG("ib_lock", "+WAIT(" << lock << ") " << *lock);
}
/** Reset the wait status of a lock.
@@ -662,26 +662,21 @@ 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);
+ DBUG_LOG("ib_lock", "-WAIT(" << lock << ") " << *lock);
}
-inline
-bool ib_lock_t::is_stronger(ulint precise_mode, ulint heap_no, const trx_t* t) const
+inline bool ib_lock_t::is_stronger(ulint precise_mode, ulint heap_no,
+ const trx_t *t) const
{
- ut_ad(is_record_lock());
- return trx == t
- && !is_waiting()
- && !is_insert_intention()
- && (!is_record_not_gap()
- || (precise_mode & LOCK_REC_NOT_GAP) /* only record */
- || heap_no == PAGE_HEAP_NO_SUPREMUM)
- && (!is_gap()
- || (precise_mode & LOCK_GAP) /* only gap */
- || heap_no == PAGE_HEAP_NO_SUPREMUM)
- && lock_mode_stronger_or_eq(
- mode(),
- static_cast<lock_mode>(
- precise_mode & LOCK_MODE_MASK));
+ ut_ad(is_record_lock());
+ return trx == t && !is_waiting() && !is_insert_intention() &&
+ (!is_record_not_gap() ||
+ (precise_mode & LOCK_REC_NOT_GAP) /* only record */
+ || heap_no == PAGE_HEAP_NO_SUPREMUM) &&
+ (!is_gap() || (precise_mode & LOCK_GAP) /* only gap */
+ || heap_no == PAGE_HEAP_NO_SUPREMUM) &&
+ lock_mode_stronger_or_eq(
+ mode(), static_cast<lock_mode>(precise_mode & LOCK_MODE_MASK));
}
#include "lock0priv.ic"
diff --git a/storage/innobase/include/lock0types.h b/storage/innobase/include/lock0types.h
index b2c0506dcd4..6b58e15f701 100644
--- a/storage/innobase/include/lock0types.h
+++ b/storage/innobase/include/lock0types.h
@@ -56,20 +56,20 @@ const char* lock_mode_string(enum lock_mode mode)
{
switch (mode) {
case LOCK_IS:
- return("IS");
- case LOCK_IX:
- return("IX");
- case LOCK_S:
- return("S");
- case LOCK_X:
- return("X");
- case LOCK_AUTO_INC:
- return("AUTO_INC");
- case LOCK_NONE:
- return("NONE");
- case LOCK_NONE_UNSET:
- return("NONE_UNSET");
- default:
+ return ("IS");
+ case LOCK_IX:
+ return ("IX");
+ case LOCK_S:
+ return ("S");
+ case LOCK_X:
+ return ("X");
+ case LOCK_AUTO_INC:
+ return ("AUTO_INC");
+ case LOCK_NONE:
+ return ("NONE");
+ case LOCK_NONE_UNSET:
+ return ("NONE_UNSET");
+ default:
ut_error;
}
}
@@ -175,49 +175,51 @@ operator<<(std::ostream& out, const lock_rec_t& lock)
#endif
/* @} */
-inline
-const char*
-type_string(ulint type_mode)
+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;
- }
+ 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)
+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());
+ 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 */
@@ -281,14 +283,12 @@ struct ib_lock_t
return(type_mode & LOCK_INSERT_INTENTION);
}
- bool is_stronger(ulint precise_mode, ulint heap_no, const trx_t* t) const;
+ bool is_stronger(ulint precise_mode, ulint heap_no,
+ const trx_t *t) const;
- ulint type() const
- {
- return(type_mode & LOCK_TYPE_MASK);
- }
+ ulint type() const { return (type_mode & LOCK_TYPE_MASK); }
- enum lock_mode mode() const
+ enum lock_mode mode() const
{
return(static_cast<enum lock_mode>(type_mode & LOCK_MODE_MASK));
}
@@ -298,15 +298,12 @@ 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);
- }
+ std::string type_mode_string() const
+ {
+ return ::type_mode_string(type_mode);
+ }
- const char* type_string() const
- {
- return ::type_string(type_mode);
- }
+ const char *type_string() const { return ::type_string(type_mode); }
};
typedef UT_LIST_BASE_NODE_T(ib_lock_t) trx_lock_list_t;
@@ -316,63 +313,55 @@ typedef UT_LIST_BASE_NODE_T(ib_lock_t) trx_lock_list_t;
struct VICTIM /* deadlock victim */
{
- const trx_t *trx;
- bool set;
- VICTIM(const trx_t *t, bool s = true) : trx(t), set(s)
- {
- }
+ 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)
+inline std::ostream &operator<<(std::ostream &out, const VICTIM &v)
{
- out << (v.set ? '+' : '-') << "VICTIM(trx=" << v.trx << ") ";
- return out;
+ 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)
- {
- }
+ 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)
+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;
+ 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 */
+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)
- {
- }
+ 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)
+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;
+ 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 */
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index d8caadbd11b..3aed796cec2 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -1030,8 +1030,8 @@ lock_rec_has_expl(
{
lock_t* lock;
- DBUG_ENTER("lock_rec_has_expl");
- ut_ad(lock_mutex_own());
+ 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);
ut_ad(!(precise_mode & LOCK_INSERT_INTENTION));
@@ -1040,14 +1040,15 @@ lock_rec_has_expl(
lock != NULL;
lock = lock_rec_get_next(heap_no, lock)) {
- if (lock->is_stronger(precise_mode, heap_no, trx)) {
+ if (lock->is_stronger(precise_mode, heap_no, trx))
+ {
- DBUG_LOG("ib_lock", WEAKER(precise_mode, lock));
- DBUG_RETURN(lock);
- }
- }
+ DBUG_LOG("ib_lock", WEAKER(precise_mode, lock));
+ DBUG_RETURN(lock);
+ }
+ }
- DBUG_RETURN(NULL);
+ DBUG_RETURN(NULL);
}
#ifdef UNIV_DEBUG
@@ -1135,57 +1136,58 @@ static void wsrep_kill_victim(const trx_t * const trx, const lock_t *lock)
Checks if some other transaction has a conflicting explicit lock request
in the queue, so that we have to wait.
@return lock or NULL */
-static
-lock_t*
-lock_rec_other_has_conflicting(
-/*===========================*/
- ulint mode, /*!< in: LOCK_S or LOCK_X,
- possibly ORed to LOCK_GAP or
- LOCK_REC_NOT_GAP,
- LOCK_INSERT_INTENTION */
- const buf_block_t* block, /*!< in: buffer block containing
- the record */
- ulint heap_no,/*!< in: heap number of the record */
- const trx_t* trx) /*!< in: our transaction */
-{
- lock_t* res = NULL;
-
- DBUG_ENTER("lock_rec_other_has_conflicting");
- ut_ad(lock_mutex_own());
+static lock_t *lock_rec_other_has_conflicting(
+ /*===========================*/
+ ulint mode, /*!< in: LOCK_S or LOCK_X,
+ possibly ORed to LOCK_GAP or
+ LOCK_REC_NOT_GAP,
+ LOCK_INSERT_INTENTION */
+ const buf_block_t *block, /*!< in: buffer block containing
+ the record */
+ ulint heap_no, /*!< in: heap number of the record */
+ const trx_t *trx) /*!< in: our transaction */
+{
+ lock_t *res= NULL;
+
+ DBUG_ENTER("lock_rec_other_has_conflicting");
+ ut_ad(lock_mutex_own());
- bool is_supremum = (heap_no == PAGE_HEAP_NO_SUPREMUM);
+ bool is_supremum= (heap_no == PAGE_HEAP_NO_SUPREMUM);
- for (lock_t* lock = lock_rec_get_first(lock_sys.rec_hash, block, heap_no);
- lock != NULL;
- lock = lock_rec_get_next(heap_no, lock)) {
+ for (lock_t *lock= lock_rec_get_first(lock_sys.rec_hash, block, heap_no);
+ lock != NULL; lock= lock_rec_get_next(heap_no, lock))
+ {
- /* 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)) {
+ /* 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);
- }
+ DBUG_LOG("ib_lock", CONFLICTS(trx, mode, NULL)
+ << "because: " << WEAKER(mode, lock));
+ DBUG_RETURN(NULL);
+ }
- if (!res && lock_rec_has_to_wait(true, trx, mode, lock, is_supremum)) {
- res = lock;
- }
- }
+ if (!res && lock_rec_has_to_wait(true, trx, mode, lock, is_supremum))
+ {
+ res= lock;
+ }
+ }
#ifdef WITH_WSREP
- if (res && trx->is_wsrep()) {
- trx_mutex_enter(res->trx);
- /* Below function will roll back either trx
- or lock->trx depending on priority of the
- transaction. */
- wsrep_kill_victim(const_cast<trx_t*>(trx), res);
- trx_mutex_exit(res->trx);
- }
+ if (res && trx->is_wsrep())
+ {
+ trx_mutex_enter(res->trx);
+ /* Below function will roll back either trx
+ or lock->trx depending on priority of the
+ transaction. */
+ wsrep_kill_victim(const_cast<trx_t *>(trx), res);
+ trx_mutex_exit(res->trx);
+ }
#endif /* WITH_WSREP */
- DBUG_LOG("ib_lock", CONFLICTS(trx, mode, res));
- DBUG_RETURN(res);
+ DBUG_LOG("ib_lock", CONFLICTS(trx, mode, res));
+ DBUG_RETURN(res);
}
/*********************************************************************//**
@@ -1410,8 +1412,8 @@ 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);
+ 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);
@@ -1439,11 +1441,12 @@ 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;
+ 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)) {
- wsrep_print_wait_locks(c_lock);
+ if (UNIV_UNLIKELY(wsrep_debug))
+ {
+ wsrep_print_wait_locks(c_lock);
}
trx->lock.que_state = TRX_QUE_LOCK_WAIT;
@@ -3505,8 +3508,8 @@ 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;
+ 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)) {
wsrep_report_bf_lock_wait(trx->mysql_thd, trx->id);
@@ -3532,8 +3535,8 @@ 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);
+ DBUG_LOG("ib_lock", "ADD(" << lock << ") " << *lock);
+ lock->trx->lock.table_locks.push_back(lock);
MONITOR_INC(MONITOR_TABLELOCK_CREATED);
MONITOR_INC(MONITOR_NUM_TABLELOCK);
@@ -3668,9 +3671,9 @@ 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);
+ DBUG_LOG("ib_lock", "DEL(" << lock << ") " << *lock);
- MONITOR_INC(MONITOR_TABLELOCK_REMOVED);
+ MONITOR_INC(MONITOR_TABLELOCK_REMOVED);
MONITOR_DEC(MONITOR_NUM_TABLELOCK);
}
@@ -3716,8 +3719,8 @@ lock_table_enqueue_waiting(
#ifdef WITH_WSREP
if (trx->is_wsrep() && trx->lock.was_chosen_as_deadlock_victim) {
- DBUG_LOG("ib_lock", "DEADLOCK(" << trx << ") ");
- return(DB_DEADLOCK);
+ DBUG_LOG("ib_lock", "DEADLOCK(" << trx << ") ");
+ return (DB_DEADLOCK);
}
#endif /* WITH_WSREP */
@@ -3739,8 +3742,8 @@ 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);
+ DBUG_LOG("ib_lock", "DEADLOCK(" << trx << ") ");
+ return(DB_DEADLOCK);
} else if (trx->lock.wait_lock == NULL) {
/* Deadlock resolution chose another transaction as a victim,
@@ -3752,8 +3755,8 @@ 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;
+ DBUG_LOG("ib_lock", VICTIM(trx, false));
+ trx->lock.was_chosen_as_deadlock_victim = false;
ut_a(que_thr_stop(thr));
@@ -5418,9 +5421,9 @@ 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);
+ 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);
}
lock_mutex_exit();
@@ -6923,8 +6926,8 @@ DeadlockChecker::trx_rollback()
trx_mutex_enter(trx);
- DBUG_LOG("ib_lock", VICTIM(trx));
- trx->lock.was_chosen_as_deadlock_victim = true;
+ 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 f6de4364650..764c14453c9 100644
--- a/storage/innobase/lock/lock0wait.cc
+++ b/storage/innobase/lock/lock0wait.cc
@@ -267,8 +267,8 @@ 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;
+ DBUG_LOG("ib_lock", "DEADLOCK(" << trx << ") ");
+ trx->lock.was_chosen_as_deadlock_victim = false;
}
lock_wait_mutex_exit();
@@ -444,8 +444,8 @@ 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;
+ DBUG_LOG("ib_lock", "DEADLOCK(" << trx << ") ");
+ trx->lock.was_chosen_as_deadlock_victim = false;
}
os_event_set(thr->slot->event);
diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
index 412e41bb5c8..d836d90c22f 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -5739,14 +5739,17 @@ not_moved:
lock_wait_or_error:
if (!dict_index_is_spatial(index)) {
- /* Locked gap may be filled with inserted records.
- Make sure we don't miss them. */
- if (moves_up) {
- btr_pcur_move_to_prev(pcur, &mtr);
- } else {
- btr_pcur_move_to_next(pcur, &mtr);
- }
- btr_pcur_store_position(pcur, &mtr);
+ /* Locked gap may be filled with inserted records.
+ Make sure we don't miss them. */
+ if (moves_up)
+ {
+ btr_pcur_move_to_prev(pcur, &mtr);
+ }
+ else
+ {
+ btr_pcur_move_to_next(pcur, &mtr);
+ }
+ btr_pcur_store_position(pcur, &mtr);
}
page_read_error:
/* Reset the old and new "did semi-consistent read" flags. */
@@ -5788,17 +5791,23 @@ lock_table_wait:
sel_restore_position_for_mysql(
&same_user_rec, BTR_SEARCH_LEAF, pcur,
moves_up, &mtr);
- /* Counterpart of the stepping backward in lock_wait_or_error.
- This is linked tight with that btr_pcur_store_position().
- The jumps to page_read_error: and lock_table_wait: do not get here. */
- if (same_user_rec) {
- if (!moves_up) {
- btr_pcur_move_to_prev(pcur, &mtr);
- } else {
- btr_pcur_move_to_next(pcur, &mtr);
- }
- }
- }
+ /* Counterpart of the stepping backward in
+ lock_wait_or_error. This is linked tight with that
+ btr_pcur_store_position(). The jumps to
+ page_read_error: and lock_table_wait: do not get here.
+ */
+ if (same_user_rec)
+ {
+ if (!moves_up)
+ {
+ btr_pcur_move_to_prev(pcur, &mtr);
+ }
+ else
+ {
+ btr_pcur_move_to_next(pcur, &mtr);
+ }
+ }
+ }
if ((srv_locks_unsafe_for_binlog
|| trx->isolation_level <= TRX_ISO_READ_COMMITTED)
diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc
index 39e58bdc03e..afc90431113 100644
--- a/storage/innobase/ut/ut0ut.cc
+++ b/storage/innobase/ut/ut0ut.cc
@@ -676,36 +676,26 @@ const char * dbug_print_rec(const rec_t* rec, dict_index_t* index)
static std::string dbug_str;
-template <class T>
-const char * dbug_print(T &obj)
+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();
+ 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(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_rec_t *obj) { return dbug_print(*obj); }
-const char * dbug_print(lock_table_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)
+const char *dbug_print_lock_mode(ib_uint32_t type_mode)
{
- dbug_str = type_mode_string(type_mode);
- return dbug_str.c_str();
+ dbug_str= type_mode_string(type_mode);
+ return dbug_str.c_str();
}
#endif /* !DBUG_OFF */
#endif /* !UNIV_INNOCHECKSUM */