diff options
Diffstat (limited to 'innobase/trx/trx0trx.c')
-rw-r--r-- | innobase/trx/trx0trx.c | 82 |
1 files changed, 47 insertions, 35 deletions
diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c index 0197e5cc05f..b509d80e452 100644 --- a/innobase/trx/trx0trx.c +++ b/innobase/trx/trx0trx.c @@ -73,7 +73,9 @@ trx_create( { trx_t* trx; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ trx = mem_alloc(sizeof(trx_t)); @@ -171,8 +173,7 @@ trx_allocate_for_mysql(void) /* Open a dummy session */ if (!trx_dummy_sess) { - trx_dummy_sess = sess_open(NULL, (byte*)"Dummy sess", - ut_strlen((char *) "Dummy sess")); + trx_dummy_sess = sess_open(); } trx = trx_create(trx_dummy_sess); @@ -205,8 +206,7 @@ trx_allocate_for_background(void) /* Open a dummy session */ if (!trx_dummy_sess) { - trx_dummy_sess = sess_open(NULL, (byte*)"Dummy sess", - ut_strlen("Dummy sess")); + trx_dummy_sess = sess_open(); } trx = trx_create(trx_dummy_sess); @@ -241,7 +241,9 @@ trx_free( { char err_buf[1000]; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ if (trx->declared_to_be_inside_innodb) { ut_print_timestamp(stderr); @@ -347,7 +349,9 @@ trx_list_insert_ordered( { trx_t* trx2; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ trx2 = UT_LIST_GET_FIRST(trx_sys->trx_list); @@ -509,7 +513,9 @@ trx_assign_rseg(void) { trx_rseg_t* rseg = trx_sys->latest_rseg; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ loop: /* Get next rseg in a round-robin fashion */ @@ -546,7 +552,9 @@ trx_start_low( { trx_rseg_t* rseg; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(trx->rseg == NULL); if (trx->type == TRX_PURGE) { @@ -621,7 +629,9 @@ trx_commit_off_kernel( ibool must_flush_log = FALSE; mtr_t mtr; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ rseg = trx->rseg; @@ -715,7 +725,9 @@ trx_commit_off_kernel( } ut_ad(trx->conc_state == TRX_ACTIVE); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ /* The following assignment makes the transaction committed in memory and makes its changes to data visible to other transactions. @@ -804,7 +816,7 @@ trx_commit_off_kernel( log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE); } else { - ut_a(0); + ut_error; } trx->commit_lsn = lsn; @@ -895,7 +907,9 @@ trx_handle_commit_sig_off_kernel( trx_sig_t* sig; trx_sig_t* next_sig; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ trx->que_state = TRX_QUE_COMMITTING; @@ -913,7 +927,7 @@ trx_handle_commit_sig_off_kernel( if (sig->type == TRX_SIG_COMMIT) { - trx_sig_reply(trx, sig, next_thr); + trx_sig_reply(sig, next_thr); trx_sig_remove(trx, sig); } @@ -935,7 +949,9 @@ trx_end_lock_wait( { que_thr_t* thr; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(trx->que_state == TRX_QUE_LOCK_WAIT); thr = UT_LIST_GET_FIRST(trx->wait_thrs); @@ -962,7 +978,9 @@ trx_lock_wait_to_suspended( { que_thr_t* thr; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(trx->que_state == TRX_QUE_LOCK_WAIT); thr = UT_LIST_GET_FIRST(trx->wait_thrs); @@ -990,7 +1008,9 @@ trx_sig_reply_wait_to_suspended( trx_sig_t* sig; que_thr_t* thr; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ sig = UT_LIST_GET_FIRST(trx->reply_signals); @@ -1002,7 +1022,6 @@ trx_sig_reply_wait_to_suspended( thr->state = QUE_THR_SUSPENDED; sig->receiver = NULL; - sig->reply = FALSE; UT_LIST_REMOVE(reply_signals, trx->reply_signals, sig); @@ -1024,7 +1043,9 @@ trx_sig_is_compatible( { trx_sig_t* sig; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ if (UT_LIST_GET_LEN(trx->signals) == 0) { @@ -1096,13 +1117,9 @@ trx_sig_send( ulint type, /* in: signal type */ ulint sender, /* in: TRX_SIG_SELF or TRX_SIG_OTHER_SESS */ - ibool reply, /* in: TRUE if the sender of the signal - wants reply after the operation induced - by the signal is completed; if type - is TRX_SIG_END_WAIT, this must be - FALSE */ que_thr_t* receiver_thr, /* in: query thread which wants the - reply, or NULL */ + reply, or NULL; if type is + TRX_SIG_END_WAIT, this must be NULL */ trx_savept_t* savept, /* in: possible rollback savepoint, or NULL */ que_thr_t** next_thr) /* in/out: next query thread to run; @@ -1116,13 +1133,15 @@ trx_sig_send( trx_t* receiver_trx; ut_ad(trx); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ if (!trx_sig_is_compatible(trx, type, sender)) { /* The signal is not compatible with the other signals in the queue: do nothing */ - ut_a(0); + ut_error; return(FALSE); } @@ -1146,7 +1165,6 @@ trx_sig_send( sig->type = type; sig->state = TRX_SIG_WAITING; sig->sender = sender; - sig->reply = reply; sig->receiver = receiver_thr; if (savept) { @@ -1171,7 +1189,7 @@ trx_sig_send( signal to the end of the queue, if the session is not yet in the error state: */ - ut_a(0); + ut_error; } /* If there were no other signals ahead in the queue, try to start @@ -1196,7 +1214,9 @@ trx_end_signal_handling( /*====================*/ trx_t* trx) /* in: trx */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(trx->handling_signals == TRUE); trx->handling_signals = FALSE; @@ -1230,7 +1250,9 @@ loop: we can process immediately */ ut_ad(trx); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ if (trx->handling_signals && (UT_LIST_GET_LEN(trx->signals) == 0)) { @@ -1305,7 +1327,7 @@ loop: } else if (type == TRX_SIG_BREAK_EXECUTION) { - trx_sig_reply(trx, sig, next_thr); + trx_sig_reply(sig, next_thr); trx_sig_remove(trx, sig); } else { ut_error; @@ -1321,7 +1343,6 @@ handled. */ void trx_sig_reply( /*==========*/ - trx_t* trx, /* in: trx handle */ trx_sig_t* sig, /* in: signal */ que_thr_t** next_thr) /* in/out: next query thread to run; if the value which is passed in is @@ -1331,11 +1352,12 @@ trx_sig_reply( { trx_t* receiver_trx; - ut_ad(trx && sig); + ut_ad(sig); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ - if (sig->reply && (sig->receiver != NULL)) { - + if (sig->receiver != NULL) { ut_ad((sig->receiver)->state == QUE_THR_SIG_REPLY_WAIT); receiver_trx = thr_get_trx(sig->receiver); @@ -1346,18 +1368,8 @@ trx_sig_reply( que_thr_end_wait(sig->receiver, next_thr); - sig->reply = FALSE; - sig->receiver = NULL; - - } else if (sig->reply) { - /* In this case the reply should be sent to the client of - the session of the transaction */ - - sig->reply = FALSE; sig->receiver = NULL; - sess_srv_msg_send_simple(trx->sess, SESS_SRV_SUCCESS, - SESS_NOT_RELEASE_KERNEL); } } @@ -1371,9 +1383,10 @@ trx_sig_remove( trx_sig_t* sig) /* in, own: signal */ { ut_ad(trx && sig); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ - ut_ad(sig->reply == FALSE); ut_ad(sig->receiver == NULL); UT_LIST_REMOVE(signals, trx->signals, sig); @@ -1435,8 +1448,7 @@ trx_commit_step( /* Send the commit signal to the transaction */ success = trx_sig_send(thr_get_trx(thr), TRX_SIG_COMMIT, - TRX_SIG_SELF, TRUE, thr, NULL, - &next_thr); + TRX_SIG_SELF, thr, NULL, &next_thr); mutex_exit(&kernel_mutex); @@ -1522,7 +1534,7 @@ trx_commit_complete_for_mysql( log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE); } else { - ut_a(0); + ut_error; } trx->op_info = (char*)""; |