Commit 469da6c3 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 7ebabea5
...@@ -5377,7 +5377,7 @@ btr_cur_del_mark_set_clust_rec( ...@@ -5377,7 +5377,7 @@ btr_cur_del_mark_set_clust_rec(
DBUG_LOG("ib_cur", DBUG_LOG("ib_cur",
"delete-mark clust " << index->table->name "delete-mark clust " << index->table->name
<< " (" << index->id << ") by " << " (" << index->id << ") by "
<< ib::hex(trx_get_id_for_print(trx)) << ": " << ib::hex(trx->id) << ": "
<< rec_printer(rec, offsets).str()); << rec_printer(rec, offsets).str());
if (dict_index_is_online_ddl(index)) { if (dict_index_is_online_ddl(index)) {
......
...@@ -342,19 +342,6 @@ trx_get_que_state_str( ...@@ -342,19 +342,6 @@ trx_get_que_state_str(
/*==================*/ /*==================*/
const trx_t* trx); /*!< in: transaction */ 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 */ /** Create the trx_t pool */
void void
trx_pool_init(); trx_pool_init();
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -106,42 +106,6 @@ trx_get_que_state_str( ...@@ -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. Determine if a transaction is a dictionary operation.
@return dictionary operation mode */ @return dictionary operation mode */
......
...@@ -1757,7 +1757,7 @@ static void lock_grant_after_reset(lock_t* lock) ...@@ -1757,7 +1757,7 @@ static void lock_grant_after_reset(lock_t* lock)
} }
DBUG_PRINT("ib_lock", ("wait for trx " TRX_ID_FMT " ends", 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 /* If we are resolving a deadlock by choosing another transaction
as a victim, then our original transaction may not be in the 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) ...@@ -3928,7 +3928,7 @@ lock_table_print(FILE* file, const lock_t* lock)
fputs("TABLE LOCK table ", file); fputs("TABLE LOCK table ", file);
ut_print_name(file, lock->trx, ut_print_name(file, lock->trx,
lock->un_member.tab_lock.table->name.m_name); 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) { if (lock_get_mode(lock) == LOCK_S) {
fputs(" lock mode S", file); fputs(" lock mode S", file);
...@@ -3971,7 +3971,7 @@ static void lock_rec_print(FILE* file, const lock_t* lock, mtr_t& mtr) ...@@ -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_rec_get_n_bits(lock),
lock->index->name()); lock->index->name());
ut_print_name(file, lock->trx, lock->index->table->name.m_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) { if (lock_get_mode(lock) == LOCK_S) {
fputs(" lock mode S", file); fputs(" lock mode S", file);
...@@ -5458,17 +5458,6 @@ lock_get_type( ...@@ -5458,17 +5458,6 @@ lock_get_type(
return(lock_get_type_low(lock)); return(lock_get_type_low(lock));
} }
/*******************************************************************//**
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. Gets the table on which the lock is.
@return table */ @return table */
......
...@@ -424,7 +424,7 @@ fill_trx_row( ...@@ -424,7 +424,7 @@ fill_trx_row(
lock_sys.mutex_assert_locked(); 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_started = trx->start_time;
row->trx_state = trx_get_que_state_str(trx); row->trx_state = trx_get_que_state_str(trx);
row->requested_lock_row = requested_lock_row; row->requested_lock_row = requested_lock_row;
......
...@@ -1766,7 +1766,11 @@ trx_print_low( ...@@ -1766,7 +1766,11 @@ trx_print_low(
ibool newline; ibool newline;
const char* op_info; 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) { switch (trx->state) {
case TRX_STATE_NOT_STARTED: case TRX_STATE_NOT_STARTED:
......
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