diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 0a0a02b1a50..8272bb67e49 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1406,15 +1406,12 @@ which case still the trx->no is assigned. @param[in,out] trx the modified transaction @return true if added to the serialisation_list (non read-only trx) */ static inline bool trx_add_to_serialisation_list(trx_t *trx) { - trx_sys_serialisation_mutex_enter(); - trx->no = trx_sys_allocate_trx_no(); /* Update the latest transaction number. */ ut_d(trx_sys->rw_max_trx_no = trx->no); if (trx->read_only) { - trx_sys_serialisation_mutex_exit(); return false; } @@ -1424,7 +1421,6 @@ static inline bool trx_add_to_serialisation_list(trx_t *trx) { trx_sys->serialisation_min_trx_no.store(trx->no); } - trx_sys_serialisation_mutex_exit(); return true; } @@ -1486,10 +1482,12 @@ static bool trx_serialisation_number_get( elem.insert(temp_rseg); } - mutex_enter(&purge_sys->pq_mutex); - + trx_sys_serialisation_mutex_enter(); added_trx_no = trx_add_to_serialisation_list(trx); + mutex_enter(&purge_sys->pq_mutex); + trx_sys_serialisation_mutex_exit(); + elem.set_trx_no(trx->no); purge_sys->purge_queue->push(std::move(elem)); @@ -1497,7 +1495,9 @@ static bool trx_serialisation_number_get( mutex_exit(&purge_sys->pq_mutex); } else { + trx_sys_serialisation_mutex_enter(); added_trx_no = trx_add_to_serialisation_list(trx); + trx_sys_serialisation_mutex_exit(); } return (added_trx_no);