MCPcopy Create free account
hub / github.com/MariaDB/server / binlog_commit

Function binlog_commit

sql/log.cc:2802–2919  ·  view source on GitHub ↗

This function is called once after each statement. It has the responsibility to flush the caches to the binary log on commits. @param thd The client thread that executes the transaction. @param all This is @c true if this is a real transaction commit, and @false otherwise. @param ro_1pc read-only one-phase commit transaction */

Source from the content-addressed store, hash-verified

2800 @param ro_1pc read-only one-phase commit transaction
2801*/
2802int binlog_commit(THD *thd, bool all, bool ro_1pc)
2803{
2804 int error= 0;
2805 PSI_stage_info org_stage;
2806 DBUG_ENTER("binlog_commit");
2807
2808 bool is_ending_transaction= ending_trans(thd, all);
2809
2810 binlog_cache_mngr *const cache_mngr= thd->binlog_get_cache_mngr();
2811 /*
2812 cache_mngr can be NULL in case if binlog logging is disabled.
2813 */
2814 if (!cache_mngr)
2815 {
2816 DBUG_ASSERT(WSREP(thd) ||
2817 (thd->lex->sql_command != SQLCOM_XA_PREPARE &&
2818 !(thd->lex->sql_command == SQLCOM_XA_COMMIT &&
2819 thd->lex->xa_opt == XA_ONE_PHASE)));
2820
2821 DBUG_RETURN(0);
2822 }
2823 /*
2824 This is true if we are doing an alter table that is replicated as
2825 CREATE TABLE ... SELECT
2826 */
2827 if (thd->variables.option_bits & OPTION_BIN_COMMIT_OFF)
2828 DBUG_RETURN(0);
2829
2830 DBUG_PRINT("debug",
2831 ("all: %d, in_transaction: %s, all.modified_non_trans_table: %s, stmt.modified_non_trans_table: %s",
2832 all,
2833 YESNO(thd->in_multi_stmt_transaction_mode()),
2834 YESNO(thd->transaction->all.modified_non_trans_table),
2835 YESNO(thd->transaction->stmt.modified_non_trans_table)));
2836
2837 thd->backup_stage(&org_stage);
2838 THD_STAGE_INFO(thd, stage_binlog_write);
2839 if (!cache_mngr->stmt_cache.empty())
2840 {
2841#ifdef WITH_WSREP
2842 if (wsrep_on(thd) && !ending_trans(thd, all))
2843 {
2844 /*
2845 We should not clear stmt cache in case we are in transaction.
2846 However we should write all pending row events to disk to
2847 ensure we did not run out of disk quota.
2848 */
2849 error= thd->binlog_flush_pending_rows_event(TRUE, FALSE);
2850 }
2851 else
2852#endif /* WITH_WSREP */
2853 error= binlog_commit_flush_stmt_cache(thd, all, cache_mngr);
2854 }
2855 if (cache_mngr->trx_cache.empty() &&
2856 (thd->transaction->xid_state.get_state_code() != XA_PREPARED ||
2857 !(thd->ha_data[binlog_tp.slot].ha_info[1].is_started() &&
2858 thd->ha_data[binlog_tp.slot].ha_info[1].is_trx_read_write())))
2859 {

Callers 4

commit_one_phase_2Function · 0.85
log_xa_prepareMethod · 0.85
binlog_commit_by_xidFunction · 0.85
mysql_alter_tableFunction · 0.85

Calls 15

ending_transFunction · 0.85
is_preparing_xaFunction · 0.85
binlog_get_cache_mngrMethod · 0.80
backup_stageMethod · 0.80
get_state_codeMethod · 0.80
set_prev_positionMethod · 0.80
wsrep_onFunction · 0.70

Tested by

no test coverage detected