Skip to content

Commit 469da6c

Browse files
committed
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.
1 parent 7ebabea commit 469da6c

File tree

6 files changed

+11
-67
lines changed

6 files changed

+11
-67
lines changed

storage/innobase/btr/btr0cur.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5377,7 +5377,7 @@ btr_cur_del_mark_set_clust_rec(
53775377
DBUG_LOG("ib_cur",
53785378
"delete-mark clust " << index->table->name
53795379
<< " (" << index->id << ") by "
5380-
<< ib::hex(trx_get_id_for_print(trx)) << ": "
5380+
<< ib::hex(trx->id) << ": "
53815381
<< rec_printer(rec, offsets).str());
53825382

53835383
if (dict_index_is_online_ddl(index)) {

storage/innobase/include/trx0trx.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -342,19 +342,6 @@ trx_get_que_state_str(
342342
/*==================*/
343343
const trx_t* trx); /*!< in: transaction */
344344

345-
/** Retreieves the transaction ID.
346-
In a given point in time it is guaranteed that IDs of the running
347-
transactions are unique. The values returned by this function for readonly
348-
transactions may be reused, so a subsequent RO transaction may get the same ID
349-
as a RO transaction that existed in the past. The values returned by this
350-
function should be used for printing purposes only.
351-
@param[in] trx transaction whose id to retrieve
352-
@return transaction id */
353-
UNIV_INLINE
354-
trx_id_t
355-
trx_get_id_for_print(
356-
const trx_t* trx);
357-
358345
/** Create the trx_t pool */
359346
void
360347
trx_pool_init();

storage/innobase/include/trx0trx.ic

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22

33
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2016, 2019, MariaDB Corporation.
4+
Copyright (c) 2016, 2021, MariaDB Corporation.
55

66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -106,42 +106,6 @@ trx_get_que_state_str(
106106
}
107107
}
108108

109-
/** Retreieves the transaction ID.
110-
In a given point in time it is guaranteed that IDs of the running
111-
transactions are unique. The values returned by this function for readonly
112-
transactions may be reused, so a subsequent RO transaction may get the same ID
113-
as a RO transaction that existed in the past. The values returned by this
114-
function should be used for printing purposes only.
115-
@param[in] trx transaction whose id to retrieve
116-
@return transaction id */
117-
UNIV_INLINE
118-
trx_id_t
119-
trx_get_id_for_print(
120-
const trx_t* trx)
121-
{
122-
/* Readonly and transactions whose intentions are unknown (whether
123-
they will eventually do a WRITE) don't have trx_t::id assigned (it is
124-
0 for those transactions). Transaction IDs in
125-
innodb_trx.trx_id,
126-
innodb_locks.lock_id,
127-
innodb_locks.lock_trx_id,
128-
innodb_lock_waits.requesting_trx_id,
129-
innodb_lock_waits.blocking_trx_id should match because those tables
130-
could be used in an SQL JOIN on those columns. Also trx_t::id is
131-
printed by SHOW ENGINE INNODB STATUS, and in logs, so we must have the
132-
same value printed everywhere consistently. */
133-
134-
/* DATA_TRX_ID_LEN is the storage size in bytes. */
135-
static const trx_id_t max_trx_id
136-
= (1ULL << (DATA_TRX_ID_LEN * CHAR_BIT)) - 1;
137-
138-
ut_ad(trx->id <= max_trx_id);
139-
140-
return(trx->id != 0
141-
? trx->id
142-
: reinterpret_cast<trx_id_t>(trx) | (max_trx_id + 1));
143-
}
144-
145109
/**********************************************************************//**
146110
Determine if a transaction is a dictionary operation.
147111
@return dictionary operation mode */

storage/innobase/lock/lock0lock.cc

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ static void lock_grant_after_reset(lock_t* lock)
17571757
}
17581758

17591759
DBUG_PRINT("ib_lock", ("wait for trx " TRX_ID_FMT " ends",
1760-
trx_get_id_for_print(lock->trx)));
1760+
lock->trx->id));
17611761

17621762
/* If we are resolving a deadlock by choosing another transaction
17631763
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)
39283928
fputs("TABLE LOCK table ", file);
39293929
ut_print_name(file, lock->trx,
39303930
lock->un_member.tab_lock.table->name.m_name);
3931-
fprintf(file, " trx id " TRX_ID_FMT, trx_get_id_for_print(lock->trx));
3931+
fprintf(file, " trx id " TRX_ID_FMT, lock->trx->id);
39323932

39333933
if (lock_get_mode(lock) == LOCK_S) {
39343934
fputs(" lock mode S", file);
@@ -3971,7 +3971,7 @@ static void lock_rec_print(FILE* file, const lock_t* lock, mtr_t& mtr)
39713971
lock_rec_get_n_bits(lock),
39723972
lock->index->name());
39733973
ut_print_name(file, lock->trx, lock->index->table->name.m_name);
3974-
fprintf(file, " trx id " TRX_ID_FMT, trx_get_id_for_print(lock->trx));
3974+
fprintf(file, " trx id " TRX_ID_FMT, lock->trx->id);
39753975

39763976
if (lock_get_mode(lock) == LOCK_S) {
39773977
fputs(" lock mode S", file);
@@ -5458,17 +5458,6 @@ lock_get_type(
54585458
return(lock_get_type_low(lock));
54595459
}
54605460

5461-
/*******************************************************************//**
5462-
Gets the id of the transaction owning a lock.
5463-
@return transaction id */
5464-
trx_id_t
5465-
lock_get_trx_id(
5466-
/*============*/
5467-
const lock_t* lock) /*!< in: lock */
5468-
{
5469-
return(trx_get_id_for_print(lock->trx));
5470-
}
5471-
54725461
/*******************************************************************//**
54735462
Gets the table on which the lock is.
54745463
@return table */

storage/innobase/trx/trx0i_s.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ fill_trx_row(
424424

425425
lock_sys.mutex_assert_locked();
426426

427-
row->trx_id = trx_get_id_for_print(trx);
427+
row->trx_id = trx->id;
428428
row->trx_started = trx->start_time;
429429
row->trx_state = trx_get_que_state_str(trx);
430430
row->requested_lock_row = requested_lock_row;

storage/innobase/trx/trx0trx.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,11 @@ trx_print_low(
17661766
ibool newline;
17671767
const char* op_info;
17681768

1769-
fprintf(f, "TRANSACTION " TRX_ID_FMT, trx_get_id_for_print(trx));
1769+
if (const trx_id_t id = trx->id) {
1770+
fprintf(f, "TRANSACTION " TRX_ID_FMT, trx->id);
1771+
} else {
1772+
fprintf(f, "TRANSACTION (%p)", trx);
1773+
}
17701774

17711775
switch (trx->state) {
17721776
case TRX_STATE_NOT_STARTED:

0 commit comments

Comments
 (0)