diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-01-26 08:39:11 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-01-27 15:45:38 +0200 |
commit | 469da6c34ddde8efabdded63aa3b74b1470f9c00 (patch) | |
tree | 11311a90d5bdc1bc6f514846b455d2f1e1c6f87c | |
parent | 7ebabea5d35e7bfad5cf846952d3a3db658b09ba (diff) | |
download | mariadb-git-469da6c34ddde8efabdded63aa3b74b1470f9c00.tar.gz |
Cleanup: Remove trx_get_id_for_print()
Any transaction that has requested a lock must have trx->id!=0.
trx_print_low(): Distinguish non-locking or inactive transaction
objects by displaying the pointer in parentheses.
fill_trx_row(): Do not try to map trx->id to a pointer-based value.
-rw-r--r-- | storage/innobase/btr/btr0cur.cc | 2 | ||||
-rw-r--r-- | storage/innobase/include/trx0trx.h | 13 | ||||
-rw-r--r-- | storage/innobase/include/trx0trx.ic | 38 | ||||
-rw-r--r-- | storage/innobase/lock/lock0lock.cc | 17 | ||||
-rw-r--r-- | storage/innobase/trx/trx0i_s.cc | 2 | ||||
-rw-r--r-- | storage/innobase/trx/trx0trx.cc | 6 |
6 files changed, 11 insertions, 67 deletions
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 6add764279a..e327a363834 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -5377,7 +5377,7 @@ btr_cur_del_mark_set_clust_rec( DBUG_LOG("ib_cur", "delete-mark clust " << index->table->name << " (" << index->id << ") by " - << ib::hex(trx_get_id_for_print(trx)) << ": " + << ib::hex(trx->id) << ": " << rec_printer(rec, offsets).str()); if (dict_index_is_online_ddl(index)) { diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index d9049fce924..ff44208a152 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -342,19 +342,6 @@ trx_get_que_state_str( /*==================*/ const trx_t* trx); /*!< in: transaction */ -/** Retreieves the transaction ID. -In a given point in time it is guaranteed that IDs of the running -transactions are unique. The values returned by this function for readonly -transactions may be reused, so a subsequent RO transaction may get the same ID -as a RO transaction that existed in the past. The values returned by this -function should be used for printing purposes only. -@param[in] trx transaction whose id to retrieve -@return transaction id */ -UNIV_INLINE -trx_id_t -trx_get_id_for_print( - const trx_t* trx); - /** Create the trx_t pool */ void trx_pool_init(); diff --git a/storage/innobase/include/trx0trx.ic b/storage/innobase/include/trx0trx.ic index 9fa4136f743..d9a68cbb6a6 100644 --- a/storage/innobase/include/trx0trx.ic +++ b/storage/innobase/include/trx0trx.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 2016, 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 Free Software @@ -106,42 +106,6 @@ trx_get_que_state_str( } } -/** Retreieves the transaction ID. -In a given point in time it is guaranteed that IDs of the running -transactions are unique. The values returned by this function for readonly -transactions may be reused, so a subsequent RO transaction may get the same ID -as a RO transaction that existed in the past. The values returned by this -function should be used for printing purposes only. -@param[in] trx transaction whose id to retrieve -@return transaction id */ -UNIV_INLINE -trx_id_t -trx_get_id_for_print( - const trx_t* trx) -{ - /* Readonly and transactions whose intentions are unknown (whether - they will eventually do a WRITE) don't have trx_t::id assigned (it is - 0 for those transactions). Transaction IDs in - innodb_trx.trx_id, - innodb_locks.lock_id, - innodb_locks.lock_trx_id, - innodb_lock_waits.requesting_trx_id, - innodb_lock_waits.blocking_trx_id should match because those tables - could be used in an SQL JOIN on those columns. Also trx_t::id is - printed by SHOW ENGINE INNODB STATUS, and in logs, so we must have the - same value printed everywhere consistently. */ - - /* DATA_TRX_ID_LEN is the storage size in bytes. */ - static const trx_id_t max_trx_id - = (1ULL << (DATA_TRX_ID_LEN * CHAR_BIT)) - 1; - - ut_ad(trx->id <= max_trx_id); - - return(trx->id != 0 - ? trx->id - : reinterpret_cast<trx_id_t>(trx) | (max_trx_id + 1)); -} - /**********************************************************************//** Determine if a transaction is a dictionary operation. @return dictionary operation mode */ diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index c51e24b5bad..c522b30785d 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1757,7 +1757,7 @@ static void lock_grant_after_reset(lock_t* lock) } DBUG_PRINT("ib_lock", ("wait for trx " TRX_ID_FMT " ends", - trx_get_id_for_print(lock->trx))); + lock->trx->id)); /* If we are resolving a deadlock by choosing another transaction as a victim, then our original transaction may not be in the @@ -3928,7 +3928,7 @@ lock_table_print(FILE* file, const lock_t* lock) fputs("TABLE LOCK table ", file); ut_print_name(file, lock->trx, lock->un_member.tab_lock.table->name.m_name); - fprintf(file, " trx id " TRX_ID_FMT, trx_get_id_for_print(lock->trx)); + fprintf(file, " trx id " TRX_ID_FMT, lock->trx->id); if (lock_get_mode(lock) == LOCK_S) { fputs(" lock mode S", file); @@ -3971,7 +3971,7 @@ static void lock_rec_print(FILE* file, const lock_t* lock, mtr_t& mtr) lock_rec_get_n_bits(lock), lock->index->name()); ut_print_name(file, lock->trx, lock->index->table->name.m_name); - fprintf(file, " trx id " TRX_ID_FMT, trx_get_id_for_print(lock->trx)); + fprintf(file, " trx id " TRX_ID_FMT, lock->trx->id); if (lock_get_mode(lock) == LOCK_S) { fputs(" lock mode S", file); @@ -5459,17 +5459,6 @@ lock_get_type( } /*******************************************************************//** -Gets the id of the transaction owning a lock. -@return transaction id */ -trx_id_t -lock_get_trx_id( -/*============*/ - const lock_t* lock) /*!< in: lock */ -{ - return(trx_get_id_for_print(lock->trx)); -} - -/*******************************************************************//** Gets the table on which the lock is. @return table */ UNIV_INLINE diff --git a/storage/innobase/trx/trx0i_s.cc b/storage/innobase/trx/trx0i_s.cc index a24562211b6..b911f2b014b 100644 --- a/storage/innobase/trx/trx0i_s.cc +++ b/storage/innobase/trx/trx0i_s.cc @@ -424,7 +424,7 @@ fill_trx_row( lock_sys.mutex_assert_locked(); - row->trx_id = trx_get_id_for_print(trx); + row->trx_id = trx->id; row->trx_started = trx->start_time; row->trx_state = trx_get_que_state_str(trx); row->requested_lock_row = requested_lock_row; diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 2ba782e2f1c..b3ba666b92e 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1766,7 +1766,11 @@ trx_print_low( ibool newline; const char* op_info; - fprintf(f, "TRANSACTION " TRX_ID_FMT, trx_get_id_for_print(trx)); + if (const trx_id_t id = trx->id) { + fprintf(f, "TRANSACTION " TRX_ID_FMT, trx->id); + } else { + fprintf(f, "TRANSACTION (%p)", trx); + } switch (trx->state) { case TRX_STATE_NOT_STARTED: |