@@ -1423,19 +1423,12 @@ innobase_close_connection(
1423
1423
THD* thd); /*!< in: MySQL thread handle for
1424
1424
which to close the connection */
1425
1425
1426
+ /** Cancel any pending lock request associated with the current THD.
1427
+ @sa THD::awake() @sa ha_kill_query() */
1428
+ static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels);
1426
1429
static void innobase_commit_ordered(handlerton *hton, THD* thd, bool all);
1427
1430
static void innobase_checkpoint_request(handlerton *hton, void *cookie);
1428
1431
1429
- /*****************************************************************//**
1430
- Cancel any pending lock request associated with the current THD. */
1431
- static
1432
- void
1433
- innobase_kill_connection(
1434
- /*======================*/
1435
- handlerton* hton, /*!< in: innobase handlerton */
1436
- THD* thd, /*!< in: handle to the MySQL thread being killed */
1437
- thd_kill_levels);
1438
-
1439
1432
/*****************************************************************//**
1440
1433
Commits a transaction in an InnoDB database or marks an SQL statement
1441
1434
ended.
@@ -3886,7 +3879,7 @@ innobase_init(
3886
3879
innobase_hton->release_temporary_latches =
3887
3880
innobase_release_temporary_latches;
3888
3881
3889
- innobase_hton->kill_query = innobase_kill_connection ;
3882
+ innobase_hton->kill_query = innobase_kill_query ;
3890
3883
3891
3884
if (srv_file_per_table)
3892
3885
innobase_hton->tablefile_extensions = ha_innobase_exts;
@@ -5496,20 +5489,11 @@ ha_innobase::get_row_type() const
5496
5489
return(ROW_TYPE_NOT_USED);
5497
5490
}
5498
5491
5499
- /*****************************************************************//**
5500
- Cancel any pending lock request associated with the current THD. */
5501
- static
5502
- void
5503
- innobase_kill_connection(
5504
- /*======================*/
5505
- handlerton* hton, /*!< in: innobase handlerton */
5506
- THD* thd, /*!< in: handle to the MySQL thread being killed */
5507
- thd_kill_levels)
5492
+ /** Cancel any pending lock request associated with the current THD.
5493
+ @sa THD::awake() @sa ha_kill_query() */
5494
+ static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels)
5508
5495
{
5509
- trx_t* trx;
5510
-
5511
- DBUG_ENTER("innobase_kill_connection");
5512
- DBUG_ASSERT(hton == innodb_hton_ptr);
5496
+ DBUG_ENTER("innobase_kill_query");
5513
5497
5514
5498
#ifdef WITH_WSREP
5515
5499
wsrep_thd_LOCK(thd);
@@ -5525,50 +5509,10 @@ innobase_kill_connection(
5525
5509
}
5526
5510
wsrep_thd_UNLOCK(thd);
5527
5511
#endif /* WITH_WSREP */
5528
- trx = thd_to_trx(thd);
5529
-
5530
- if (trx && trx->lock.wait_lock) {
5531
- /* In wsrep BF we have already took lock_sys and trx
5532
- mutex either on wsrep_abort_transaction() or
5533
- before wsrep_kill_victim(). In replication we
5534
- could own lock_sys mutex taken in
5535
- lock_deadlock_check_and_resolve().*/
5536
-
5537
- WSREP_DEBUG("Killing victim trx %p BF %d trx BF %d trx_id " TRX_ID_FMT " ABORT %d thd %p"
5538
- " current_thd %p BF %d wait_lock_modes: %s\n",
5539
- trx, wsrep_thd_is_BF(trx->mysql_thd, FALSE),
5540
- wsrep_thd_is_BF(thd, FALSE),
5541
- trx->id, trx->abort_type,
5542
- trx->mysql_thd,
5543
- current_thd,
5544
- wsrep_thd_is_BF(current_thd, FALSE),
5545
- lock_get_info(trx->lock.wait_lock).c_str());
5546
-
5547
- if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)
5548
- && trx->abort_type == TRX_SERVER_ABORT) {
5549
- ut_ad(!lock_mutex_own());
5550
- lock_mutex_enter();
5551
- }
5552
-
5553
- if (trx->abort_type != TRX_WSREP_ABORT) {
5554
- trx_mutex_enter(trx);
5555
- }
5556
-
5557
- ut_ad(lock_mutex_own());
5558
- ut_ad(trx_mutex_own(trx));
5559
-
5560
- if (trx->lock.wait_lock) {
5561
- lock_cancel_waiting_and_release(trx->lock.wait_lock);
5562
- }
5563
-
5564
- if (trx->abort_type != TRX_WSREP_ABORT) {
5565
- trx_mutex_exit(trx);
5566
- }
5567
-
5568
- if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE) &&
5569
- trx->abort_type == TRX_SERVER_ABORT) {
5570
- lock_mutex_exit();
5571
- }
5512
+ if (trx_t* trx = thd_to_trx(thd)) {
5513
+ ut_ad(trx->mysql_thd == thd);
5514
+ /* Cancel a pending lock request if there are any */
5515
+ lock_trx_handle_wait(trx);
5572
5516
}
5573
5517
5574
5518
DBUG_VOID_RETURN;
@@ -19802,7 +19746,7 @@ wsrep_innobase_kill_one_trx(
19802
19746
thd_get_thread_id(thd)));
19803
19747
WSREP_DEBUG("kill query for: %ld",
19804
19748
thd_get_thread_id(thd));
19805
- /* Note that innobase_kill_connection will take lock_mutex
19749
+ /* Note that innobase_kill_query will take lock_mutex
19806
19750
and trx_mutex */
19807
19751
wsrep_thd_UNLOCK(thd);
19808
19752
wsrep_thd_awake(thd, signal);
0 commit comments