From 74a0a9877bd936d60f24810e34773d742caab0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 Jun 2021 12:09:12 +0300 Subject: [PATCH] MDEV-24731 fixup: Another bogus assertion In commit de407e7cb4d12574806bf4f7830e73908d5ca9e2 a debug assertion was added that would not always hold: We could have TRX_STATE_PREPARED here. But, in that case, the transaction should not have been chosen as a deadlock victim. --- storage/innobase/lock/lock0lock.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 95cb27aba10..5c5d43f7c76 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1850,11 +1850,15 @@ static void lock_wait_end(trx_t *trx) { mysql_mutex_assert_owner(&lock_sys.wait_mutex); ut_ad(trx->mutex_is_owner()); - ut_ad(trx->state == TRX_STATE_ACTIVE); + ut_d(const auto state= trx->state); + ut_ad(state == TRX_STATE_ACTIVE || state == TRX_STATE_PREPARED); ut_ad(trx->lock.wait_thr); if (trx->lock.was_chosen_as_deadlock_victim.fetch_and(byte(~1))) + { + ut_ad(state == TRX_STATE_ACTIVE); trx->error_state= DB_DEADLOCK; + } trx->lock.wait_thr= nullptr; pthread_cond_signal(&trx->lock.cond);