diff options
Diffstat (limited to 'innobase/trx/trx0trx.c')
-rw-r--r-- | innobase/trx/trx0trx.c | 122 |
1 files changed, 54 insertions, 68 deletions
diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c index 3926cfa03c5..54358ad3d4c 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; @@ -650,29 +660,6 @@ trx_commit_off_kernel( if (undo) { mutex_enter(&kernel_mutex); -#ifdef notdefined - /* !!!!!!!!! There is a bug here: purge and rollback - need the whole stack of old record versions even if no - consistent read would need them!! This is because they - decide on the basis of the old versions when we can - remove delete marked secondary index records! */ - - if (!undo->del_marks && (undo->size == 1) - && (UT_LIST_GET_LEN(trx_sys->view_list) == 1)) { - - /* There is no need to save the update undo - log: discard it; note that &mtr gets committed - while we must hold the kernel mutex and - therefore this optimization may add to the - contention of the kernel mutex. */ - - lsn = trx_undo_update_cleanup_by_discard(trx, - &mtr); - mutex_exit(&(rseg->mutex)); - - goto shortcut; - } -#endif trx->no = trx_sys_get_new_trx_no(); mutex_exit(&kernel_mutex); @@ -714,11 +701,13 @@ trx_commit_off_kernel( TRX_SYS_MYSQL_MASTER_LOG_INFO, &mtr); } - /* If we did not take the shortcut, the following call - commits the mini-transaction, making the whole transaction - committed in the file-based world at this log sequence number; - otherwise, we get the commit lsn from the call of - trx_undo_update_cleanup_by_discard above. + /* The following call commits the mini-transaction, making the + whole transaction committed in the file-based world, at this + log sequence number. The transaction becomes 'durable' when + we write the log to disk, but in the logical sense the commit + in the file-based data structures (undo logs etc.) happens + here. + NOTE that transaction numbers, which are assigned only to transactions with an update undo log, do not necessarily come in exactly the same order as commit lsn's, if the transactions @@ -738,7 +727,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. @@ -827,7 +818,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; @@ -918,7 +909,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; @@ -936,7 +929,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); } @@ -958,7 +951,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); @@ -985,7 +980,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); @@ -1013,7 +1010,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); @@ -1025,7 +1024,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); @@ -1047,7 +1045,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) { @@ -1119,13 +1119,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; @@ -1139,16 +1135,16 @@ 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; - /* sess_raise_error_low(trx, 0, 0, NULL, NULL, NULL, NULL, - "Incompatible signal"); */ return(FALSE); } @@ -1171,7 +1167,6 @@ trx_sig_send( sig->type = type; sig->state = TRX_SIG_WAITING; sig->sender = sender; - sig->reply = reply; sig->receiver = receiver_thr; if (savept) { @@ -1196,10 +1191,7 @@ trx_sig_send( signal to the end of the queue, if the session is not yet in the error state: */ - ut_a(0); - - sess_raise_error_low(trx, 0, 0, NULL, NULL, NULL, NULL, - (char *) "Signal from another session, or a break execution signal"); + ut_error; } /* If there were no other signals ahead in the queue, try to start @@ -1224,7 +1216,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; @@ -1258,7 +1252,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)) { @@ -1333,7 +1329,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; @@ -1349,7 +1345,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 @@ -1359,11 +1354,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); @@ -1374,18 +1370,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); } } @@ -1399,9 +1385,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); @@ -1463,8 +1450,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); @@ -1550,7 +1536,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*)""; |