Commit 03dcdad2 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-22697 - InnoDB: remove trx->no

trx->no is duplicated by trx->rw_trx_hash_element->no for no good reason.
The latter is preferred for performance reasons: allows to avoid taking
trx->rw_trx_hash_element->mutex when snapshotting.
parent 50b0ce44
......@@ -363,6 +363,13 @@ struct rw_trx_hash_element_t
trx_id_t id; /* lf_hash_init() relies on this to be first in the struct */
/**
Transaction serialization number.
Assigned shortly before the transaction is moved to COMMITTED_IN_MEMORY
state. Initially set to TRX_ID_MAX.
*/
Atomic_counter<trx_id_t> no;
trx_t *trx;
ib_mutex_t mutex;
......@@ -930,8 +937,7 @@ class trx_sys_t
*/
void assign_new_trx_no(trx_t *trx)
{
trx->no= get_new_trx_id_no_refresh();
trx->rw_trx_hash_element->no= trx->no;
trx->rw_trx_hash_element->no= get_new_trx_id_no_refresh();
refresh_rw_trx_hash_version();
}
......@@ -955,7 +961,7 @@ class trx_sys_t
@param[in,out] caller_trx used to get access to rw_trx_hash_pins
@param[out] ids array to store registered transaction identifiers
@param[out] max_trx_id variable to store m_max_trx_id value
@param[out] mix_trx_no variable to store min(trx->no) value
@param[out] mix_trx_no variable to store min(no) value
*/
void snapshot_ids(trx_t *caller_trx, trx_ids_t *ids, trx_id_t *max_trx_id,
......
......@@ -734,15 +734,6 @@ struct trx_t {
trx_id_t id; /*!< transaction id */
trx_id_t no; /*!< transaction serialization number:
max trx id shortly before the
transaction is moved to
COMMITTED_IN_MEMORY state.
Accessed exclusively by trx owner
thread. Should be removed in favour of
trx->rw_trx_hash_element->no.
Initially set to TRX_ID_MAX. */
/** State of the trx from the point of view of concurrency control
and the valid state transitions.
......
......@@ -210,7 +210,7 @@ void
trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr)
{
DBUG_PRINT("trx", ("commit(" TRX_ID_FMT "," TRX_ID_FMT ")",
trx->id, trx->no));
trx->id, trx->rw_trx_hash_element->no));
ut_ad(undo == trx->rsegs.m_redo.undo
|| undo == trx->rsegs.m_redo.old_insert);
trx_rseg_t* rseg = trx->rsegs.m_redo.rseg;
......@@ -301,7 +301,8 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr)
+ TRX_UNDO_HISTORY_NODE), mtr);
mtr->write<8,mtr_t::MAYBE_NOP>(*undo_page,
undo_header + TRX_UNDO_TRX_NO, trx->no);
undo_header + TRX_UNDO_TRX_NO,
trx->rw_trx_hash_element->no);
/* This is needed for upgrading old undo log pages from
before MariaDB 10.3.1. */
if (UNIV_UNLIKELY(!mach_read_from_2(undo_header
......@@ -313,7 +314,8 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr)
if (rseg->last_page_no == FIL_NULL) {
rseg->last_page_no = undo->hdr_page_no;
rseg->last_offset = undo->hdr_offset;
rseg->set_last_trx_no(trx->no, undo == trx->rsegs.m_redo.undo);
rseg->set_last_trx_no(trx->rw_trx_hash_element->no,
undo == trx->rsegs.m_redo.undo);
rseg->needs_purge = true;
}
......
......@@ -104,8 +104,6 @@ trx_init(
/*=====*/
trx_t* trx)
{
trx->no = TRX_ID_MAX;
trx->state = TRX_STATE_NOT_STARTED;
trx->is_recovered = false;
......@@ -677,7 +675,6 @@ static void trx_resurrect(trx_undo_t *undo, trx_rseg_t *rseg,
trx->state= state;
ut_d(trx->start_file= __FILE__);
ut_d(trx->start_line= __LINE__);
ut_ad(trx->no == TRX_ID_MAX);
if (is_old_insert)
trx->rsegs.m_redo.old_insert= undo;
......@@ -966,11 +963,6 @@ trx_start_low(
trx->xid->null();
#endif /* WITH_WSREP */
/* The initial value for trx->no: TRX_ID_MAX is used in
read_view_open_now: */
trx->no = TRX_ID_MAX;
ut_a(ib_vector_is_empty(trx->autoinc_locks));
ut_a(trx->lock.table_locks.empty());
......@@ -1046,7 +1038,8 @@ trx_serialise(trx_t* trx)
already in the rollback segment. User threads only
produce events when a rollback segment is empty. */
if (rseg->last_page_no == FIL_NULL) {
purge_sys.purge_queue.push(TrxUndoRsegs(trx->no, *rseg));
purge_sys.purge_queue.push(TrxUndoRsegs(trx->rw_trx_hash_element->no,
*rseg));
mutex_exit(&purge_sys.pq_mutex);
}
}
......
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