From a6cff02a2fc0d963c82c4a0e17b78be77562863a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 17 May 2021 08:37:59 +0300 Subject: [PATCH] MDEV-25687: Remove trx_active_transactions MONITOR_TRX_ACTIVE: Remove. The count is not being updated consistently, and it would also include read-only transactions that are otherwise fully invisible to any other threads. If it later turns out that a reliable count of active transactions is needed, it can be exposed via a different interface. trx_commit_for_mysql(): If the transaction was not started, return immediately. --- .../suite/innodb/r/innodb_skip_innodb_is_tables.result | 1 - mysql-test/suite/innodb/r/monitor.result | 4 +--- mysql-test/suite/innodb/t/monitor.test | 2 +- storage/innobase/include/srv0mon.h | 3 +-- storage/innobase/srv/srv0mon.cc | 5 ----- storage/innobase/trx/trx0roll.cc | 2 -- storage/innobase/trx/trx0trx.cc | 9 +-------- .../rocksdb/r/innodb_i_s_tables_disabled.result | 1 - 8 files changed, 4 insertions(+), 23 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result index 0f0d3169779..9e87ee53f35 100644 --- a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result +++ b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result @@ -167,7 +167,6 @@ trx_nl_ro_commits transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL N trx_commits_insert_update transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions committed with inserts and updates trx_rollbacks transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back trx_rollbacks_savepoint transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back to savepoint -trx_active_transactions transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of active transactions trx_rseg_history_len transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Length of the TRX_RSEG_HISTORY list trx_undo_slots_used transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots used trx_undo_slots_cached transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots cached diff --git a/mysql-test/suite/innodb/r/monitor.result b/mysql-test/suite/innodb/r/monitor.result index 152941ce54e..b6883250128 100644 --- a/mysql-test/suite/innodb/r/monitor.result +++ b/mysql-test/suite/innodb/r/monitor.result @@ -133,7 +133,6 @@ trx_nl_ro_commits disabled trx_commits_insert_update disabled trx_rollbacks disabled trx_rollbacks_savepoint disabled -trx_active_transactions disabled trx_rseg_history_len disabled trx_undo_slots_used disabled trx_undo_slots_cached disabled @@ -426,10 +425,9 @@ select name, max_count, min_count, count, max_count_reset, min_count_reset, count_reset, if(enabled,'enabled','disabled') status from information_schema.innodb_metrics -where name like "trx_rollbacks" or name like "trx_active_transactions"; +where name='trx_rollbacks'; name max_count min_count count max_count_reset min_count_reset count_reset status trx_rollbacks 1 NULL 1 1 NULL 1 enabled -trx_active_transactions 1 0 0 1 0 0 enabled set global innodb_monitor_disable = module_trx; set global innodb_monitor_enable = module_dml; insert into monitor_test values(9); diff --git a/mysql-test/suite/innodb/t/monitor.test b/mysql-test/suite/innodb/t/monitor.test index 7fa0c64f81b..38ff520aeae 100644 --- a/mysql-test/suite/innodb/t/monitor.test +++ b/mysql-test/suite/innodb/t/monitor.test @@ -268,7 +268,7 @@ select name, max_count, min_count, count, max_count_reset, min_count_reset, count_reset, if(enabled,'enabled','disabled') status from information_schema.innodb_metrics -where name like "trx_rollbacks" or name like "trx_active_transactions"; +where name='trx_rollbacks'; set global innodb_monitor_disable = module_trx; diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h index 569898cdd78..3faf4f7b7b0 100644 --- a/storage/innobase/include/srv0mon.h +++ b/storage/innobase/include/srv0mon.h @@ -2,7 +2,7 @@ Copyright (c) 2010, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2020, MariaDB Corporation. +Copyright (c) 2013, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -285,7 +285,6 @@ enum monitor_id_t { MONITOR_TRX_COMMIT_UNDO, MONITOR_TRX_ROLLBACK, MONITOR_TRX_ROLLBACK_SAVEPOINT, - MONITOR_TRX_ACTIVE, MONITOR_RSEG_HISTORY_LEN, MONITOR_NUM_UNDO_SLOT_USED, MONITOR_NUM_UNDO_SLOT_CACHED, diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index b10c07a192f..3a0338a0f71 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -723,11 +723,6 @@ static monitor_info_t innodb_counter_info[] = MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_TRX_ROLLBACK_SAVEPOINT}, - {"trx_active_transactions", "transaction", - "Number of active transactions", - MONITOR_NONE, - MONITOR_DEFAULT_START, MONITOR_TRX_ACTIVE}, - {"trx_rseg_history_len", "transaction", "Length of the TRX_RSEG_HISTORY list", static_cast( diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index 2576ac340e3..0204502e8f5 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -141,8 +141,6 @@ inline void trx_t::rollback_low(trx_savept_t *savept) } mem_heap_free(heap); - - MONITOR_DEC(MONITOR_TRX_ACTIVE); } /** Initiate rollback. diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index f68ae049b0e..dd0b9cbfed8 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -993,8 +993,6 @@ trx_start_low( : microsecond_interval_timer(); ut_a(trx->error_state == DB_SUCCESS); - - MONITOR_INC(MONITOR_TRX_ACTIVE); } /** Set the serialisation number for a persistent committed transaction. @@ -1612,17 +1610,12 @@ trx_commit_for_mysql( switch (trx->state) { case TRX_STATE_NOT_STARTED: - ut_d(trx->start_file = __FILE__); - ut_d(trx->start_line = __LINE__); - - trx_start_low(trx, true); - /* fall through */ + return DB_SUCCESS; case TRX_STATE_ACTIVE: case TRX_STATE_PREPARED: case TRX_STATE_PREPARED_RECOVERED: trx->op_info = "committing"; trx->commit(); - MONITOR_DEC(MONITOR_TRX_ACTIVE); trx->op_info = ""; return(DB_SUCCESS); case TRX_STATE_COMMITTED_IN_MEMORY: diff --git a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result index ad0e7b31af7..5afb59327a9 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result @@ -149,7 +149,6 @@ trx_nl_ro_commits transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL N trx_commits_insert_update transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions committed with inserts and updates trx_rollbacks transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back trx_rollbacks_savepoint transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back to savepoint -trx_active_transactions transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of active transactions trx_rseg_history_len transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Length of the TRX_RSEG_HISTORY list trx_undo_slots_used transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots used trx_undo_slots_cached transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots cached