diff options
Diffstat (limited to 'storage/xtradb/trx/trx0trx.c')
-rw-r--r-- | storage/xtradb/trx/trx0trx.c | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/storage/xtradb/trx/trx0trx.c b/storage/xtradb/trx/trx0trx.c index f150d64f8dc..9584f0c4c46 100644 --- a/storage/xtradb/trx/trx0trx.c +++ b/storage/xtradb/trx/trx0trx.c @@ -109,6 +109,8 @@ trx_create( trx->support_xa = TRUE; + trx->flush_log_at_trx_commit_session = 3; /* means to use innodb_flush_log_at_trx_commit value */ + trx->check_foreigns = TRUE; trx->check_unique_secondary = TRUE; @@ -119,7 +121,6 @@ trx_create( trx->table_id = ut_dulint_zero; trx->mysql_thd = NULL; - trx->mysql_query_str = NULL; trx->active_trans = 0; trx->duplicates = 0; @@ -736,6 +737,9 @@ trx_start( generated by the same transaction, doesn't. */ trx->support_xa = thd_supports_xa(trx->mysql_thd); + trx->flush_log_at_trx_commit_session = + thd_flush_log_at_trx_commit_session(trx->mysql_thd); + mutex_enter(&kernel_mutex); ret = trx_start_low(trx, rseg_id); @@ -758,6 +762,7 @@ trx_commit_off_kernel( trx_rseg_t* rseg; trx_undo_t* undo; mtr_t mtr; + trx_sysf_t* sys_header = NULL; ut_ad(mutex_own(&kernel_mutex)); @@ -815,7 +820,11 @@ trx_commit_off_kernel( if (trx->mysql_log_file_name && trx->mysql_log_file_name[0] != '\0') { + if (!sys_header) { + sys_header = trx_sysf_get(&mtr); + } trx_sys_update_mysql_binlog_offset( + sys_header, trx->mysql_log_file_name, trx->mysql_log_offset, TRX_SYS_MYSQL_LOG_INFO, &mtr); @@ -824,11 +833,16 @@ trx_commit_off_kernel( if (trx->mysql_master_log_file_name[0] != '\0') { /* This database server is a MySQL replication slave */ + if (!sys_header) { + sys_header = trx_sysf_get(&mtr); + } trx_sys_update_mysql_binlog_offset( + sys_header, trx->mysql_relay_log_file_name, trx->mysql_relay_log_pos, TRX_SYS_MYSQL_RELAY_LOG_INFO, &mtr); trx_sys_update_mysql_binlog_offset( + sys_header, trx->mysql_master_log_file_name, trx->mysql_master_log_pos, TRX_SYS_MYSQL_MASTER_LOG_INFO, &mtr); @@ -907,6 +921,7 @@ trx_commit_off_kernel( trx->read_view = NULL; if (lsn) { + ulint flush_log_at_trx_commit; mutex_exit(&kernel_mutex); @@ -915,6 +930,12 @@ trx_commit_off_kernel( trx_undo_insert_cleanup(trx); } + if (trx->flush_log_at_trx_commit_session == 3) { + flush_log_at_trx_commit = srv_flush_log_at_trx_commit; + } else { + flush_log_at_trx_commit = trx->flush_log_at_trx_commit_session; + } + /* NOTE that we could possibly make a group commit more efficient here: call os_thread_yield here to allow also other trxs to come to commit! */ @@ -946,9 +967,9 @@ trx_commit_off_kernel( if (trx->flush_log_later) { /* Do nothing yet */ trx->must_flush_log_later = TRUE; - } else if (srv_flush_log_at_trx_commit == 0) { + } else if (flush_log_at_trx_commit == 0) { /* Do nothing */ - } else if (srv_flush_log_at_trx_commit == 1) { + } else if (flush_log_at_trx_commit == 1) { if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) { /* Write the log but do not flush it to disk */ @@ -960,7 +981,7 @@ trx_commit_off_kernel( log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE); } - } else if (srv_flush_log_at_trx_commit == 2) { + } else if (flush_log_at_trx_commit == 2) { /* Write the log but do not flush it to disk */ @@ -983,7 +1004,6 @@ trx_commit_off_kernel( trx->rseg = NULL; trx->undo_no = ut_dulint_zero; trx->last_sql_stat_start.least_undo_no = ut_dulint_zero; - trx->mysql_query_str = NULL; ut_ad(UT_LIST_GET_LEN(trx->wait_thrs) == 0); ut_ad(UT_LIST_GET_LEN(trx->trx_locks) == 0); @@ -1641,16 +1661,23 @@ trx_commit_complete_for_mysql( trx_t* trx) /*!< in: trx handle */ { ib_uint64_t lsn = trx->commit_lsn; + ulint flush_log_at_trx_commit; ut_a(trx); trx->op_info = "flushing log"; + if (trx->flush_log_at_trx_commit_session == 3) { + flush_log_at_trx_commit = srv_flush_log_at_trx_commit; + } else { + flush_log_at_trx_commit = trx->flush_log_at_trx_commit_session; + } + if (!trx->must_flush_log_later) { /* Do nothing */ - } else if (srv_flush_log_at_trx_commit == 0) { + } else if (flush_log_at_trx_commit == 0) { /* Do nothing */ - } else if (srv_flush_log_at_trx_commit == 1) { + } else if (flush_log_at_trx_commit == 1) { if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) { /* Write the log but do not flush it to disk */ @@ -1661,7 +1688,7 @@ trx_commit_complete_for_mysql( log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE); } - } else if (srv_flush_log_at_trx_commit == 2) { + } else if (flush_log_at_trx_commit == 2) { /* Write the log but do not flush it to disk */ @@ -1922,6 +1949,8 @@ trx_prepare_off_kernel( /*--------------------------------------*/ if (lsn) { + ulint flush_log_at_trx_commit; + /* Depending on the my.cnf options, we may now write the log buffer to the log files, making the prepared state of the transaction durable if the OS does not crash. We may also @@ -1941,9 +1970,15 @@ trx_prepare_off_kernel( mutex_exit(&kernel_mutex); - if (srv_flush_log_at_trx_commit == 0) { + if (trx->flush_log_at_trx_commit_session == 3) { + flush_log_at_trx_commit = srv_flush_log_at_trx_commit; + } else { + flush_log_at_trx_commit = trx->flush_log_at_trx_commit_session; + } + + if (flush_log_at_trx_commit == 0) { /* Do nothing */ - } else if (srv_flush_log_at_trx_commit == 1) { + } else if (flush_log_at_trx_commit == 1) { if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) { /* Write the log but do not flush it to disk */ @@ -1955,7 +1990,7 @@ trx_prepare_off_kernel( log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE); } - } else if (srv_flush_log_at_trx_commit == 2) { + } else if (flush_log_at_trx_commit == 2) { /* Write the log but do not flush it to disk */ |