Commit 6dfb73a9 authored by Sergei Golubchik's avatar Sergei Golubchik

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().
parent 8b1f145c
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment