Skip to content

Commit

Permalink
MDEV-25687: Remove trx_active_transactions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed May 17, 2021
1 parent cdbd04d commit a6cff02
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions mysql-test/suite/innodb/r/monitor.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/innodb/t/monitor.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions storage/innobase/include/srv0mon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions storage/innobase/srv/srv0mon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<monitor_type_t>(
Expand Down
2 changes: 0 additions & 2 deletions storage/innobase/trx/trx0roll.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 1 addition & 8 deletions storage/innobase/trx/trx0trx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a6cff02

Please sign in to comment.