diff options
-rw-r--r-- | sql/opt_range.cc | 10 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 2 | ||||
-rw-r--r-- | storage/innobase/lock/lock0lock.c | 5 |
3 files changed, 15 insertions, 2 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 96a27899db0..39f684e1928 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8469,9 +8469,13 @@ int QUICK_ROR_INTERSECT_SELECT::get_next() do { + DBUG_EXECUTE_IF("innodb_quick_report_deadlock", + DBUG_SET("+d,innodb_report_deadlock");); if ((error= quick->get_next())) { - quick_with_last_rowid->file->unlock_row(); + /* On certain errors like deadlock, trx might be rolled back.*/ + if (!current_thd->transaction_rollback_request) + quick_with_last_rowid->file->unlock_row(); DBUG_RETURN(error); } quick->file->position(quick->record); @@ -8494,7 +8498,9 @@ int QUICK_ROR_INTERSECT_SELECT::get_next() quick->file->unlock_row(); /* row not in range; unlock */ if ((error= quick->get_next())) { - quick_with_last_rowid->file->unlock_row(); + /* On certain errors like deadlock, trx might be rolled back.*/ + if (!current_thd->transaction_rollback_request) + quick_with_last_rowid->file->unlock_row(); DBUG_RETURN(error); } } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 570344ecce3..b549e19307f 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5596,6 +5596,8 @@ ha_innobase::unlock_row(void) { DBUG_ENTER("ha_innobase::unlock_row"); + ut_ad(prebuilt->trx->conc_state == TRX_ACTIVE); + /* Consistent read does not take any locks, thus there is nothing to unlock. */ diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c index a72be540c1b..a5ce43496af 100644 --- a/storage/innobase/lock/lock0lock.c +++ b/storage/innobase/lock/lock0lock.c @@ -1997,6 +1997,8 @@ lock_rec_lock_fast( || mode - (LOCK_MODE_MASK & mode) == 0 || mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP); + DBUG_EXECUTE_IF("innodb_report_deadlock", return(LOCK_REC_FAIL);); + lock = lock_rec_get_first_on_page(block); trx = thr_get_trx(thr); @@ -2074,6 +2076,8 @@ lock_rec_lock_slow( trx = thr_get_trx(thr); + DBUG_EXECUTE_IF("innodb_report_deadlock", return(DB_DEADLOCK);); + lock = lock_rec_has_expl(mode, block, heap_no, trx); if (lock) { if (lock->type_mode & LOCK_CONV_BY_OTHER) { @@ -4124,6 +4128,7 @@ lock_rec_unlock( ut_ad(trx && rec); ut_ad(block->frame == page_align(rec)); + ut_ad(trx->conc_state == TRX_ACTIVE); heap_no = page_rec_get_heap_no(rec); |