diff options
Diffstat (limited to 'innobase/trx')
-rw-r--r-- | innobase/trx/trx0purge.c | 37 | ||||
-rw-r--r-- | innobase/trx/trx0rec.c | 6 | ||||
-rw-r--r-- | innobase/trx/trx0roll.c | 32 | ||||
-rw-r--r-- | innobase/trx/trx0rseg.c | 11 | ||||
-rw-r--r-- | innobase/trx/trx0sys.c | 21 | ||||
-rw-r--r-- | innobase/trx/trx0trx.c | 82 | ||||
-rw-r--r-- | innobase/trx/trx0undo.c | 61 |
7 files changed, 169 insertions, 81 deletions
diff --git a/innobase/trx/trx0purge.c b/innobase/trx/trx0purge.c index 31223aa280e..558a0825fd7 100644 --- a/innobase/trx/trx0purge.c +++ b/innobase/trx/trx0purge.c @@ -45,7 +45,9 @@ trx_purge_update_undo_must_exist( the undo log still exists in the system */ dulint trx_id) /* in: transaction id */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED)); +#endif /* UNIV_SYNC_DEBUG */ if (!read_view_sees_trx_id(purge_sys->view, trx_id)) { @@ -195,9 +197,9 @@ void trx_purge_sys_create(void) /*======================*/ { - com_endpoint_t* com_endpoint; - +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ purge_sys = mem_alloc(sizeof(trx_purge_t)); @@ -219,9 +221,7 @@ trx_purge_sys_create(void) purge_sys->arr = trx_undo_arr_create(); - com_endpoint = (com_endpoint_t*)purge_sys; /* This is a dummy non-NULL - value */ - purge_sys->sess = sess_open(com_endpoint, (byte*)"purge_system", 13); + purge_sys->sess = sess_open(); purge_sys->trx = purge_sys->sess->trx; @@ -262,7 +262,9 @@ trx_purge_add_update_undo_to_history( ut_ad(undo); rseg = undo->rseg; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(rseg->mutex))); +#endif /* UNIV_SYNC_DEBUG */ rseg_header = trx_rsegf_get(rseg->space, rseg->page_no, mtr); @@ -276,7 +278,7 @@ trx_purge_add_update_undo_to_history( if (undo->id >= TRX_RSEG_N_SLOTS) { fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", (ulong) undo->id); - ut_a(0); + ut_error; } trx_rsegf_set_nth_undo(rseg_header, undo->id, FIL_NULL, mtr); @@ -295,8 +297,7 @@ trx_purge_add_update_undo_to_history( undo_header + TRX_UNDO_HISTORY_NODE, mtr); /* Write the trx number to the undo log header */ - mlog_write_dulint(undo_header + TRX_UNDO_TRX_NO, trx->no, MLOG_8BYTES, - mtr); + mlog_write_dulint(undo_header + TRX_UNDO_TRX_NO, trx->no, mtr); /* Write information about delete markings to the undo log header */ if (!undo->del_marks) { @@ -338,7 +339,9 @@ trx_purge_free_segment( /* printf("Freeing an update undo log segment\n"); */ +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(purge_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ loop: mtr_start(&mtr); mutex_enter(&(rseg->mutex)); @@ -434,7 +437,9 @@ trx_purge_truncate_rseg_history( ulint n_removed_logs = 0; mtr_t mtr; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(purge_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ mtr_start(&mtr); mutex_enter(&(rseg->mutex)); @@ -520,7 +525,9 @@ trx_purge_truncate_history(void) dulint limit_trx_no; dulint limit_undo_no; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(purge_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ trx_purge_arr_get_biggest(purge_sys->arr, &limit_trx_no, &limit_undo_no); @@ -560,7 +567,9 @@ trx_purge_truncate_if_arr_empty(void) /*=================================*/ /* out: TRUE if array empty */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(purge_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ if (purge_sys->arr->n_used == 0) { @@ -589,7 +598,9 @@ trx_purge_rseg_get_next_history_log( ibool del_marks; mtr_t mtr; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(purge_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ mutex_enter(&(rseg->mutex)); @@ -669,7 +680,9 @@ trx_purge_choose_next_log(void) ulint offset = 0; /* remove warning (??? bug ???) */ mtr_t mtr; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(purge_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(purge_sys->next_stored == FALSE); rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list); @@ -770,7 +783,9 @@ trx_purge_get_next_rec( ulint cmpl_info; mtr_t mtr; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(purge_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(purge_sys->next_stored); space = purge_sys->rseg->space; @@ -1001,7 +1016,7 @@ trx_purge(void) /* Should not happen */ - ut_a(0); + ut_error; return(0); } @@ -1034,11 +1049,11 @@ trx_purge(void) mutex_enter(&kernel_mutex); - thr = que_fork_start_command(purge_sys->query, SESS_COMM_EXECUTE, 0); + thr = que_fork_start_command(purge_sys->query); ut_ad(thr); -/* thr2 = que_fork_start_command(purge_sys->query, SESS_COMM_EXECUTE, 0); +/* thr2 = que_fork_start_command(purge_sys->query); ut_ad(thr2); */ diff --git a/innobase/trx/trx0rec.c b/innobase/trx/trx0rec.c index e10f019ac13..bd37a4b506b 100644 --- a/innobase/trx/trx0rec.c +++ b/innobase/trx/trx0rec.c @@ -1070,7 +1070,9 @@ trx_undo_report_row_operation( IB__FILE__, __LINE__, &mtr); +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(undo_page, SYNC_TRX_UNDO_PAGE); +#endif /* UNIV_SYNC_DEBUG */ if (op_type == TRX_UNDO_INSERT_OP) { offset = trx_undo_page_report_insert(undo_page, trx, @@ -1197,7 +1199,9 @@ trx_undo_get_undo_rec( trx_undo_rec_t** undo_rec, /* out, own: copy of the record */ mem_heap_t* heap) /* in: memory heap where copied */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED)); +#endif /* UNIV_SYNC_DEBUG */ if (!trx_purge_update_undo_must_exist(trx_id)) { @@ -1257,7 +1261,9 @@ trx_undo_prev_version_build( ulint i; char err_buf[1000]; +#ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED)); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(mtr_memo_contains(index_mtr, buf_block_align(index_rec), MTR_MEMO_PAGE_S_FIX) || mtr_memo_contains(index_mtr, buf_block_align(index_rec), diff --git a/innobase/trx/trx0roll.c b/innobase/trx/trx0roll.c index 1f053aeed89..6a25304c7ef 100644 --- a/innobase/trx/trx0roll.c +++ b/innobase/trx/trx0roll.c @@ -73,8 +73,7 @@ trx_general_rollback_for_mysql( thr = pars_complete_graph_for_exec(roll_node, trx, heap); - ut_a(thr == que_fork_start_command(que_node_get_parent(thr), - SESS_COMM_EXECUTE, 0)); + ut_a(thr == que_fork_start_command(que_node_get_parent(thr))); que_run_threads(thr); mutex_enter(&kernel_mutex); @@ -354,8 +353,7 @@ trx_rollback_or_clean_all_without_sess(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(); } mutex_exit(&kernel_mutex); @@ -418,7 +416,7 @@ loop: trx->graph = fork; - ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0)); + ut_a(thr == que_fork_start_command(fork)); trx_roll_max_undo_no = ut_conv_dulint_to_longlong(trx->undo_no); trx_roll_progress_printed_pct = 0; @@ -678,8 +676,10 @@ trx_roll_try_truncate( dulint limit; dulint biggest; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(trx->undo_mutex))); ut_ad(mutex_own(&((trx->rseg)->mutex))); +#endif /* UNIV_SYNC_DEBUG */ trx->pages_undone = 0; @@ -722,7 +722,9 @@ trx_roll_pop_top_rec( trx_undo_rec_t* prev_rec; page_t* prev_rec_page; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(trx->undo_mutex))); +#endif /* UNIV_SYNC_DEBUG */ undo_page = trx_undo_page_get_s_latched(undo->space, undo->top_page_no, mtr); @@ -946,7 +948,9 @@ trx_rollback( que_thr_t* thr; /* que_thr_t* thr2; */ +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ ut_ad((trx->undo_no_arr == NULL) || ((trx->undo_no_arr)->n_used == 0)); /* Initialize the rollback field in the transaction */ @@ -981,11 +985,11 @@ trx_rollback( trx->graph = roll_graph; trx->que_state = TRX_QUE_ROLLING_BACK; - thr = que_fork_start_command(roll_graph, SESS_COMM_EXECUTE, 0); + thr = que_fork_start_command(roll_graph); ut_ad(thr); -/* thr2 = que_fork_start_command(roll_graph, SESS_COMM_EXECUTE, 0); +/* thr2 = que_fork_start_command(roll_graph); ut_ad(thr2); */ @@ -1015,7 +1019,9 @@ trx_roll_graph_build( que_thr_t* thr; /* que_thr_t* thr2; */ +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ heap = mem_heap_create(512); fork = que_fork_create(NULL, NULL, QUE_FORK_ROLLBACK, heap); @@ -1042,7 +1048,9 @@ trx_finish_error_processing( trx_sig_t* sig; trx_sig_t* next_sig; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ sig = UT_LIST_GET_FIRST(trx->signals); @@ -1075,14 +1083,16 @@ trx_finish_partial_rollback_off_kernel( { trx_sig_t* sig; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ sig = UT_LIST_GET_FIRST(trx->signals); /* Remove the signal from the signal queue and send reply message to it */ - trx_sig_reply(trx, sig, next_thr); + trx_sig_reply(sig, next_thr); trx_sig_remove(trx, sig); trx->que_state = TRX_QUE_RUNNING; @@ -1106,7 +1116,9 @@ trx_finish_rollback_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 */ ut_a(trx->undo_no_arr == NULL || trx->undo_no_arr->n_used == 0); @@ -1145,7 +1157,7 @@ trx_finish_rollback_off_kernel( if (sig->type == TRX_SIG_TOTAL_ROLLBACK) { - trx_sig_reply(trx, sig, next_thr); + trx_sig_reply(sig, next_thr); trx_sig_remove(trx, sig); } @@ -1213,7 +1225,7 @@ trx_rollback_step( success = trx_sig_send(thr_get_trx(thr), sig_no, TRX_SIG_SELF, - TRUE, thr, savept, NULL); + thr, savept, NULL); thr->state = QUE_THR_SIG_REPLY_WAIT; diff --git a/innobase/trx/trx0rseg.c b/innobase/trx/trx0rseg.c index b1fb8a9539c..e3885c86def 100644 --- a/innobase/trx/trx0rseg.c +++ b/innobase/trx/trx0rseg.c @@ -60,7 +60,9 @@ trx_rseg_header_create( page_t* page; ut_ad(mtr); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space), MTR_MEMO_X_LOCK)); sys_header = trx_sysf_get(mtr); @@ -81,7 +83,9 @@ trx_rseg_header_create( return(FIL_NULL); } +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_RSEG_HEADER_NEW); +#endif /* UNIV_SYNC_DEBUG */ page_no = buf_frame_get_page_no(page); @@ -132,7 +136,9 @@ trx_rseg_mem_create( fil_addr_t node_addr; ulint sum_of_undo_sizes; - ut_ad(mutex_own(&kernel_mutex)); +#ifdef UNIV_SYNC_DEBUG + ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ rseg = mem_alloc(sizeof(trx_rseg_t)); @@ -173,8 +179,7 @@ trx_rseg_mem_create( + node_addr.boffset; rseg->last_trx_no = mtr_read_dulint( - undo_log_hdr + TRX_UNDO_TRX_NO, - MLOG_8BYTES, mtr); + undo_log_hdr + TRX_UNDO_TRX_NO, mtr); rseg->last_del_marks = mtr_read_ulint( undo_log_hdr + TRX_UNDO_DEL_MARKS, MLOG_2BYTES, mtr); diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c index 6084c70102f..e7439935b7e 100644 --- a/innobase/trx/trx0sys.c +++ b/innobase/trx/trx0sys.c @@ -177,7 +177,9 @@ start_again: mtr_start(&mtr); page = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr); +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_NO_ORDER_CHECK); +#endif /* UNIV_SYNC_DEBUG */ doublewrite = page + TRX_SYS_DOUBLEWRITE; @@ -211,7 +213,9 @@ start_again: /* fseg_create acquires a second latch on the page, therefore we must declare it: */ +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page2, SYNC_NO_ORDER_CHECK); +#endif /* UNIV_SYNC_DEBUG */ if (page2 == NULL) { fprintf(stderr, @@ -254,7 +258,9 @@ start_again: new_page = buf_page_get(TRX_SYS_SPACE, page_no, RW_X_LATCH, &mtr); +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(new_page, SYNC_NO_ORDER_CHECK); +#endif /* UNIV_SYNC_DEBUG */ /* Make a dummy change to the page to ensure it will be written to disk in a flush */ @@ -510,7 +516,9 @@ trx_in_trx_list( { trx_t* trx; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(kernel_mutex))); +#endif /* UNIV_SYNC_DEBUG */ trx = UT_LIST_GET_FIRST(trx_sys->trx_list); @@ -537,14 +545,16 @@ trx_sys_flush_max_trx_id(void) trx_sysf_t* sys_header; mtr_t mtr; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ mtr_start(&mtr); sys_header = trx_sysf_get(&mtr); mlog_write_dulint(sys_header + TRX_SYS_TRX_ID_STORE, - trx_sys->max_trx_id, MLOG_8BYTES, &mtr); + trx_sys->max_trx_id, &mtr); mtr_commit(&mtr); } @@ -736,7 +746,9 @@ trx_sysf_rseg_find_free( ulint page_no; ulint i; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(kernel_mutex))); +#endif /* UNIV_SYNC_DEBUG */ sys_header = trx_sysf_get(mtr); @@ -782,13 +794,15 @@ trx_sysf_create( mtr); ut_a(buf_frame_get_page_no(page) == TRX_SYS_PAGE_NO); +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_TRX_SYS_HEADER); +#endif /* UNIV_SYNC_DEBUG */ sys_header = trx_sysf_get(mtr); /* Start counting transaction ids from number 1 up */ mlog_write_dulint(sys_header + TRX_SYS_TRX_ID_STORE, - ut_dulint_create(0, 1), MLOG_8BYTES, mtr); + ut_dulint_create(0, 1), mtr); /* Reset the rollback segment slots */ for (i = 0; i < TRX_SYS_N_RSEGS; i++) { @@ -843,8 +857,7 @@ trx_sys_init_at_db_start(void) trx_sys->max_trx_id = ut_dulint_add( ut_dulint_align_up( mtr_read_dulint(sys_header - + TRX_SYS_TRX_ID_STORE, - MLOG_8BYTES, &mtr), + + TRX_SYS_TRX_ID_STORE, &mtr), TRX_SYS_TRX_ID_WRITE_MARGIN), 2 * TRX_SYS_TRX_ID_WRITE_MARGIN); 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*)""; diff --git a/innobase/trx/trx0undo.c b/innobase/trx/trx0undo.c index f3f93734a49..f2b7227d84a 100644 --- a/innobase/trx/trx0undo.c +++ b/innobase/trx/trx0undo.c @@ -391,7 +391,9 @@ trx_undo_seg_create( ibool success; ut_ad(mtr && id && rseg_hdr); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(rseg->mutex))); +#endif /* UNIV_SYNC_DEBUG */ /* if (type == TRX_UNDO_INSERT) { printf("Creating insert undo log segment\n"); @@ -431,7 +433,9 @@ trx_undo_seg_create( return(NULL); } +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(undo_page, SYNC_TRX_UNDO_PAGE); +#endif /* UNIV_SYNC_DEBUG */ page_hdr = undo_page + TRX_UNDO_PAGE_HDR; seg_hdr = undo_page + TRX_UNDO_SEG_HDR; @@ -737,13 +741,14 @@ trx_undo_add_page( ulint n_reserved; ibool success; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(trx->undo_mutex))); ut_ad(!mutex_own(&kernel_mutex)); + ut_ad(mutex_own(&(trx->rseg->mutex))); +#endif /* UNIV_SYNC_DEBUG */ rseg = trx->rseg; - ut_ad(mutex_own(&(rseg->mutex))); - if (rseg->curr_size == rseg->max_size) { return(FIL_NULL); @@ -813,8 +818,10 @@ trx_undo_free_page( UT_NOT_USED(hdr_offset); ut_a(hdr_page_no != page_no); +#ifdef UNIV_SYNC_DEBUG ut_ad(!mutex_own(&kernel_mutex)); ut_ad(mutex_own(&(rseg->mutex))); +#endif /* UNIV_SYNC_DEBUG */ undo_page = trx_undo_page_get(space, page_no, mtr); @@ -861,7 +868,9 @@ trx_undo_free_page_in_rollback( ulint last_page_no; ut_ad(undo->hdr_page_no != page_no); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(trx->undo_mutex))); +#endif /* UNIV_SYNC_DEBUG */ last_page_no = trx_undo_free_page(undo->rseg, FALSE, undo->space, undo->hdr_page_no, undo->hdr_offset, @@ -915,12 +924,13 @@ trx_undo_truncate_end( trx_rseg_t* rseg; mtr_t mtr; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(trx->undo_mutex))); + ut_ad(mutex_own(&(trx->rseg->mutex))); +#endif /* UNIV_SYNC_DEBUG */ rseg = trx->rseg; - ut_ad(mutex_own(&(rseg->mutex))); - for (;;) { mtr_start(&mtr); @@ -994,7 +1004,9 @@ trx_undo_truncate_start( ulint page_no; mtr_t mtr; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(rseg->mutex))); +#endif /* UNIV_SYNC_DEBUG */ if (0 == ut_dulint_cmp(limit, ut_dulint_zero)) { @@ -1060,8 +1072,9 @@ trx_undo_seg_free( while (!finished) { mtr_start(&mtr); - +#ifdef UNIV_SYNC_DEBUG ut_ad(!mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ mutex_enter(&(rseg->mutex)); seg_header = trx_undo_page_get(undo->space, undo->hdr_page_no, @@ -1117,7 +1130,7 @@ trx_undo_mem_create_at_db_start( if (id >= TRX_RSEG_N_SLOTS) { fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", (ulong) id); - ut_a(0); + ut_error; } undo_page = trx_undo_page_get(rseg->space, page_no, mtr); @@ -1134,8 +1147,7 @@ trx_undo_mem_create_at_db_start( undo_header = undo_page + offset; - trx_id = mtr_read_dulint(undo_header + TRX_UNDO_TRX_ID, MLOG_8BYTES, - mtr); + trx_id = mtr_read_dulint(undo_header + TRX_UNDO_TRX_ID, mtr); mutex_enter(&(rseg->mutex)); undo = trx_undo_mem_create(rseg, id, type, trx_id, page_no, offset); @@ -1145,8 +1157,7 @@ trx_undo_mem_create_at_db_start( undo->dict_operation = mtr_read_ulint( undo_header + TRX_UNDO_DICT_OPERATION, MLOG_2BYTES, mtr); - undo->table_id = mtr_read_dulint(undo_header + TRX_UNDO_TABLE_ID, - MLOG_8BYTES, mtr); + undo->table_id = mtr_read_dulint(undo_header + TRX_UNDO_TABLE_ID, mtr); undo->state = state; undo->size = flst_get_len(seg_header + TRX_UNDO_PAGE_LIST, mtr); @@ -1270,12 +1281,14 @@ trx_undo_mem_create( { trx_undo_t* undo; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(rseg->mutex))); +#endif /* UNIV_SYNC_DEBUG */ if (id >= TRX_RSEG_N_SLOTS) { fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", (ulong) id); - ut_a(0); + ut_error; } undo = mem_alloc(sizeof(trx_undo_t)); @@ -1314,14 +1327,16 @@ trx_undo_mem_init_for_reuse( is created */ ulint offset) /* in: undo log header byte offset on page */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&((undo->rseg)->mutex))); +#endif /* UNIV_SYNC_DEBUG */ if (undo->id >= TRX_RSEG_N_SLOTS) { fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", (ulong) undo->id); mem_analyze_corruption((byte*)undo); - ut_a(0); + ut_error; } undo->state = TRX_UNDO_ACTIVE; @@ -1345,7 +1360,7 @@ trx_undo_mem_free( if (undo->id >= TRX_RSEG_N_SLOTS) { fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", (ulong) undo->id); - ut_a(0); + ut_error; } mem_free(undo); @@ -1373,7 +1388,9 @@ trx_undo_create( trx_undo_t* undo; page_t* undo_page; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(rseg->mutex))); +#endif /* UNIV_SYNC_DEBUG */ if (rseg->curr_size == rseg->max_size) { @@ -1424,7 +1441,9 @@ trx_undo_reuse_cached( page_t* undo_page; ulint offset; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(rseg->mutex))); +#endif /* UNIV_SYNC_DEBUG */ if (type == TRX_UNDO_INSERT) { @@ -1448,13 +1467,12 @@ trx_undo_reuse_cached( } ut_ad(undo->size == 1); - ut_ad(undo->hdr_page_no == undo->top_page_no); if (undo->id >= TRX_RSEG_N_SLOTS) { fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", (ulong) undo->id); mem_analyze_corruption((byte*)undo); - ut_a(0); + ut_error; } undo_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr); @@ -1495,7 +1513,7 @@ trx_undo_mark_as_dict_operation( trx->dict_operation, MLOG_2BYTES, mtr); mlog_write_dulint(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID, - trx->table_id, MLOG_8BYTES, mtr); + trx->table_id, mtr); undo->dict_operation = trx->dict_operation; undo->table_id = trx->table_id; @@ -1522,11 +1540,15 @@ trx_undo_assign_undo( rseg = trx->rseg; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(trx->undo_mutex))); +#endif /* UNIV_SYNC_DEBUG */ mtr_start(&mtr); +#ifdef UNIV_SYNC_DEBUG ut_ad(!mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ mutex_enter(&(rseg->mutex)); undo = trx_undo_reuse_cached(rseg, type, trx->id, &mtr); @@ -1587,7 +1609,7 @@ trx_undo_set_state_at_finish( fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", (ulong) undo->id); mem_analyze_corruption((byte*)undo); - ut_a(0); + ut_error; } undo_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr); @@ -1632,8 +1654,9 @@ trx_undo_update_cleanup( undo = trx->update_undo; rseg = trx->rseg; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(rseg->mutex))); - +#endif /* UNIV_SYNC_DEBUG */ trx_purge_add_update_undo_to_history(trx, undo_page, mtr); UT_LIST_REMOVE(undo_list, rseg->update_undo_list, undo); @@ -1672,8 +1695,10 @@ trx_undo_update_cleanup_by_discard( undo = trx->update_undo; rseg = trx->rseg; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(rseg->mutex))); ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(undo->size == 1); ut_ad(undo->del_marks == FALSE); ut_ad(UT_LIST_GET_LEN(trx_sys->view_list) == 1); |