summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-07-01 16:38:24 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-07-01 16:38:24 +0300
commit0a67b15a9d3348d10f6df0caae6f2f973295a43a (patch)
tree97335bca6d55c2fa524517266257209af45f2b76 /storage/innobase
parent83234719f11b45d1d826f84cc7c758d939cd636d (diff)
downloadmariadb-git-0a67b15a9d3348d10f6df0caae6f2f973295a43a.tar.gz
Cleanup: Remove pointer indirection for trx_t::xid
The trx_t::xid is always allocated, so we might as well allocate it directly in the trx_t object to improve the locality of reference.
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/handler/ha_innodb.cc15
-rw-r--r--storage/innobase/include/trx0trx.h2
-rw-r--r--storage/innobase/trx/trx0purge.cc4
-rw-r--r--storage/innobase/trx/trx0trx.cc17
-rw-r--r--storage/innobase/trx/trx0undo.cc6
5 files changed, 21 insertions, 23 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 1acb8ef5e20..87c59e758b4 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -4357,7 +4357,7 @@ innobase_commit_ordered_2(
/* If the transaction is not run in 2pc, we must assign wsrep
XID here in order to get it written in rollback segment. */
if (trx->is_wsrep()) {
- thd_get_xid(thd, (MYSQL_XID*)trx->xid);
+ thd_get_xid(thd, &reinterpret_cast<MYSQL_XID&>(trx->xid));
}
#endif /* WITH_WSREP */
@@ -4552,8 +4552,9 @@ innobase_rollback(
trx is being rolled back due to BF abort, clear XID in order
to avoid writing it to rollback segment out of order. The XID
will be reassigned when the transaction is replayed. */
- if (trx->state != TRX_STATE_NOT_STARTED && wsrep_is_wsrep_xid(trx->xid)) {
- trx->xid->null();
+ if (trx->state != TRX_STATE_NOT_STARTED
+ && wsrep_is_wsrep_xid(&trx->xid)) {
+ trx->xid.null();
}
#endif /* WITH_WSREP */
if (rollback_trx
@@ -16683,7 +16684,7 @@ innobase_xa_prepare(
DBUG_ASSERT(hton == innodb_hton_ptr);
- thd_get_xid(thd, (MYSQL_XID*) trx->xid);
+ thd_get_xid(thd, &reinterpret_cast<MYSQL_XID&>(trx->xid));
if (!trx_is_registered_for_2pc(trx) && trx_is_started(trx)) {
@@ -16815,8 +16816,8 @@ int innobase_rollback_by_xid(handlerton* hton, XID* xid)
/* If a wsrep transaction is being rolled back during
the recovery, we must clear the xid in order to avoid
writing serialisation history for rolled back transaction. */
- if (wsrep_is_wsrep_xid(trx->xid)) {
- trx->xid->null();
+ if (wsrep_is_wsrep_xid(&trx->xid)) {
+ trx->xid.null();
}
#endif /* WITH_WSREP */
int ret = innobase_rollback_trx(trx);
@@ -18312,7 +18313,7 @@ void lock_wait_wsrep_kill(trx_t *bf_trx, ulong thd_id, trx_id_t trx_id)
default:
break;
case TRX_STATE_PREPARED:
- if (!wsrep_is_wsrep_xid(vtrx->xid))
+ if (!wsrep_is_wsrep_xid(&vtrx->xid))
break;
/* fall through */
case TRX_STATE_ACTIVE:
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index 1ed256eed23..b06c37e734e 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -859,7 +859,7 @@ public:
const char* start_file; /*!< Filename where it was started */
#endif /* UNIV_DEBUG */
- XID* xid; /*!< X/Open XA transaction
+ XID xid; /*!< X/Open XA transaction
identification to identify a
transaction branch */
trx_mod_tables_t mod_tables; /*!< List of tables that were modified
diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc
index 2584e534fbc..87284a5d90a 100644
--- a/storage/innobase/trx/trx0purge.cc
+++ b/storage/innobase/trx/trx0purge.cc
@@ -284,8 +284,8 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr)
&& srv_fast_shutdown));
#ifdef WITH_WSREP
- if (wsrep_is_wsrep_xid(trx->xid)) {
- trx_rseg_update_wsrep_checkpoint(rseg_header, trx->xid, mtr);
+ if (wsrep_is_wsrep_xid(&trx->xid)) {
+ trx_rseg_update_wsrep_checkpoint(rseg_header, &trx->xid, mtr);
}
#endif
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index dc7a719d5b0..b9e95b37d2f 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -178,8 +178,6 @@ struct TrxFactory {
trx->dict_operation_lock_mode = 0;
- trx->xid = UT_NEW_NOKEY(xid_t());
-
trx->detailed_error = reinterpret_cast<char*>(
ut_zalloc_nokey(MAX_DETAILED_ERROR_LEN));
@@ -231,7 +229,6 @@ struct TrxFactory {
ut_a(UT_LIST_GET_LEN(trx->lock.trx_locks) == 0);
ut_ad(UT_LIST_GET_LEN(trx->lock.evicted_tables) == 0);
- UT_DELETE(trx->xid);
ut_free(trx->detailed_error);
trx->mutex_destroy();
@@ -675,7 +672,7 @@ static void trx_resurrect(trx_undo_t *undo, trx_rseg_t *rseg,
this trx_ref_count w/o mutex protection.
*/
trx->rsegs.m_redo.rseg->acquire();
- *trx->xid= undo->xid;
+ trx->xid= undo->xid;
trx->id= undo->trx_id;
trx->is_recovered= true;
trx->start_time= start_time;
@@ -913,7 +910,7 @@ trx_start_low(
}
#ifdef WITH_WSREP
- trx->xid->null();
+ trx->xid.null();
#endif /* WITH_WSREP */
ut_a(ib_vector_is_empty(trx->autoinc_locks));
@@ -1347,7 +1344,7 @@ inline void trx_t::commit_in_memory(const mtr_t *mtr)
serialize all commits and prevent a group of transactions from
gathering. */
- commit_lsn= undo_no || !xid->is_null() ? mtr->commit_lsn() : 0;
+ commit_lsn= undo_no || !xid.is_null() ? mtr->commit_lsn() : 0;
if (!commit_lsn)
/* Nothing to be done. */;
else if (flush_log_later)
@@ -1922,7 +1919,7 @@ static my_bool trx_recover_for_mysql_callback(rw_trx_hash_element_t *element,
<< " in prepared state after recovery";
ib::info() << "Transaction contains changes to " << trx->undo_no
<< " rows";
- xid= *trx->xid;
+ xid= trx->xid;
}
}
}
@@ -1997,16 +1994,16 @@ static my_bool trx_get_trx_by_xid_callback(rw_trx_hash_element_t *element,
if (trx->is_recovered &&
(trx_state_eq(trx, TRX_STATE_PREPARED) ||
trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED)) &&
- arg->xid->eq(reinterpret_cast<XID*>(trx->xid)))
+ arg->xid->eq(&trx->xid))
{
#ifdef WITH_WSREP
/* The commit of a prepared recovered Galera
transaction needs a valid trx->xid for
invoking trx_sys_update_wsrep_checkpoint(). */
- if (!wsrep_is_wsrep_xid(trx->xid))
+ if (!wsrep_is_wsrep_xid(&trx->xid))
#endif /* WITH_WSREP */
/* Invalidate the XID, so that subsequent calls will not find it. */
- trx->xid->null();
+ trx->xid.null();
arg->trx= trx;
found= 1;
}
diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc
index 8b84cf36258..da3f6b592fa 100644
--- a/storage/innobase/trx/trx0undo.cc
+++ b/storage/innobase/trx/trx0undo.cc
@@ -1051,7 +1051,7 @@ trx_undo_create(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** undo,
uint16_t offset = trx_undo_header_create(block, trx->id, mtr);
- *undo = trx_undo_mem_create(rseg, id, trx->id, trx->xid,
+ *undo = trx_undo_mem_create(rseg, id, trx->id, &trx->xid,
block->page.id().page_no(), offset);
if (*undo == NULL) {
*err = DB_OUT_OF_MEMORY;
@@ -1109,7 +1109,7 @@ trx_undo_reuse_cached(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** pundo,
uint16_t offset = trx_undo_header_create(block, trx->id, mtr);
- trx_undo_mem_init_for_reuse(undo, trx->id, trx->xid, offset);
+ trx_undo_mem_init_for_reuse(undo, trx->id, &trx->xid, offset);
if (rseg != trx->rsegs.m_redo.rseg) {
return block;
@@ -1277,7 +1277,7 @@ void trx_undo_set_state_at_prepare(trx_t *trx, trx_undo_t *undo, bool rollback,
/*------------------------------*/
ut_ad(undo->state == TRX_UNDO_ACTIVE);
undo->state = TRX_UNDO_PREPARED;
- undo->xid = *trx->xid;
+ undo->xid = trx->xid;
/*------------------------------*/
mtr->write<2>(*block, TRX_UNDO_SEG_HDR + TRX_UNDO_STATE + block->frame,