Commit 814bc213 authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup: Use Atomic_relaxed for trx_t::state

For reading trx_t::state we can avoid acquiring trx_t::mutex.
Atomic load and store should be similar to normal load and store
on most instruction set architectures. The atomicity of the operation
would merely prohibit the compiler from reordering some operations.
parent 0bee3b8d
......@@ -656,11 +656,8 @@ class rw_trx_hash_t
trx->mutex is released, and it will have to be rechecked
by the caller after reacquiring the mutex.
*/
trx_mutex_enter(trx);
const trx_state_t state= trx->state;
trx_mutex_exit(trx);
if (state == TRX_STATE_COMMITTED_IN_MEMORY)
trx= NULL;
if (trx->state == TRX_STATE_COMMITTED_IN_MEMORY)
trx= nullptr;
else
trx->reference();
}
......
......@@ -787,7 +787,7 @@ struct trx_t : ilist_node<> {
rw_trx_hash.
Transitions to COMMITTED are protected by trx_t::mutex. */
trx_state_t state;
Atomic_relaxed<trx_state_t> state;
#ifdef WITH_WSREP
/** whether wsrep_on(mysql_thd) held at the start of transaction */
bool wsrep;
......
......@@ -5013,9 +5013,7 @@ static void lock_rec_other_trx_holds_expl(trx_t *caller_trx, trx_t *trx,
ut_ad(!page_rec_is_metadata(rec));
lock_mutex_enter();
ut_ad(trx->is_referenced());
trx_mutex_enter(trx);
const trx_state_t state = trx->state;
trx_mutex_exit(trx);
const trx_state_t state{trx->state};
ut_ad(state != TRX_STATE_NOT_STARTED);
if (state == TRX_STATE_COMMITTED_IN_MEMORY)
{
......
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