mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
bugfix: deadlock on shutdown
When slow innodb shutdown is requested, thd_destructor_proxy waits for all transactions to end, for trx_sys_any_active_transactions() == 0, and then signals purge threads to exit. But purge threads own THDs, and these THDs may own transactions too. On shutdown they'll be idle (TRX_STATE_NOT_STARTED), though, so let's skip idle transactions in trx_sys_any_active_transactions().
This commit is contained in:
parent
8b1f145c82
commit
6dfb73a97b
1 changed files with 8 additions and 2 deletions
|
@ -982,6 +982,7 @@ trx_sys_close(void)
|
|||
|
||||
/*********************************************************************
|
||||
Check if there are any active (non-prepared) transactions.
|
||||
This is only used to check if it's safe to shutdown.
|
||||
@return total number of active transactions or 0 if none */
|
||||
ulint
|
||||
trx_sys_any_active_transactions(void)
|
||||
|
@ -991,8 +992,13 @@ trx_sys_any_active_transactions(void)
|
|||
|
||||
trx_sys_mutex_enter();
|
||||
|
||||
total_trx = UT_LIST_GET_LEN(trx_sys->rw_trx_list)
|
||||
+ UT_LIST_GET_LEN(trx_sys->mysql_trx_list);
|
||||
total_trx = UT_LIST_GET_LEN(trx_sys->rw_trx_list);
|
||||
|
||||
for (trx_t* trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
|
||||
trx != NULL;
|
||||
trx = UT_LIST_GET_NEXT(mysql_trx_list, trx)) {
|
||||
total_trx += trx->state != TRX_STATE_NOT_STARTED;
|
||||
}
|
||||
|
||||
ut_a(total_trx >= trx_sys->n_prepared_trx);
|
||||
total_trx -= trx_sys->n_prepared_trx;
|
||||
|
|
Loading…
Reference in a new issue