commit 6fabfb068439325d789bcae14756b8769673c224 Author: Davi Arnaut Date: Thu Jun 18 19:51:45 2015 -0700 Bug#73114: trx_active_transactions counter in innodb_metrics goes negative after errors Do not decrement the number of activate transactions in trx_rollback_to_savepoint_low, a transaction rolled back to a save point is still active. Decrementing in trx_commit_for_mysql is not correct either as the counter is also incremented for InnoDB internal transactions. Since any active transaction needs to be committed, even rolled back transactions, the best place to decrement the counter is when a transaction is committed in memory (that is, trx_commit_in_memory). diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index bc11f1d..244b020 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -131,8 +131,6 @@ trx_rollback_to_savepoint_low( /* There might be work for utility threads.*/ srv_active_wake_master_thread(); - - MONITOR_DEC(MONITOR_TRX_ACTIVE); } /*******************************************************************//** diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 937a64a..cae351b 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1321,6 +1321,8 @@ trx_commit_in_memory( trx->error_state = DB_SUCCESS; + MONITOR_DEC(MONITOR_TRX_ACTIVE); + /* trx->in_mysql_trx_list would hold between trx_allocate_for_mysql() and trx_free_for_mysql(). It does not hold for recovered transactions or system transactions. */ @@ -1632,7 +1634,6 @@ trx_commit_for_mysql( case TRX_STATE_PREPARED: trx->op_info = "committing"; trx_commit(trx); - MONITOR_DEC(MONITOR_TRX_ACTIVE); trx->op_info = ""; return(DB_SUCCESS); case TRX_STATE_COMMITTED_IN_MEMORY: