revision-id: dfa24e558ea9fb1ace29e97383577fe4e18d0939 (mariadb-10.4.3-82-gdfa24e5) parent(s): 22e70afbd6fadcd2151e146d9b825939de2de4b8 committer: Alexey Botchkov timestamp: 2019-04-04 13:28:43 +0400 message: MDEV-7974 XA trnasactions. XID_STATE::registered_for_binlog is replaced with rw_trans flag in ha_prepare(). --- sql/handler.cc | 13 ++++++++++--- sql/log.cc | 9 ++++----- sql/sql_class.h | 1 - 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 45d21ea..f21420e 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -113,6 +113,10 @@ TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"", static TYPELIB known_extensions= {0,"known_exts", NULL, NULL}; uint known_extensions_id= 0; +static +uint +ha_check_and_coalesce_trx_read_only(THD *thd, Ha_trx_info *ha_list, + bool all); static int commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans); @@ -1247,7 +1251,6 @@ int ha_prepare(THD *thd) Ha_trx_info *ha_info= trans->ha_list; DBUG_ENTER("ha_prepare"); - thd->transaction.xid_state.registered_for_binlog= false; if (ha_info) { for (; ha_info; ha_info= ha_info->next()) @@ -1272,8 +1275,12 @@ int ha_prepare(THD *thd) } } - if (thd->transaction.xid_state.registered_for_binlog && - unlikely(tc_log->log_xa_prepare(thd, all))) + uint rw_ha_count= + ha_check_and_coalesce_trx_read_only(thd,trans->ha_list, all); + bool rw_trans= + (rw_ha_count > (thd->is_current_stmt_binlog_disabled()?0U:1U)); + + if (rw_trans && tc_log->log_xa_prepare(thd, all)) { ha_rollback_trans(thd, all); error=1; diff --git a/sql/log.cc b/sql/log.cc index 1273ccd..3819f1f 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1958,12 +1958,11 @@ binlog_truncate_trx_cache(THD *thd, binlog_cache_mngr *cache_mngr, bool all) static int binlog_prepare(handlerton *hton, THD *thd, bool all) { /* - Mark the XA for binlogging. - Transactions with no binlog handler registered like readonly ones, - should not go to the binlog. - Real work is done in MYSQL_BIN_LOG::log_xa_prepare() + do nothing. + just pretend we can do 2pc, so that MySQL won't + switch to 1pc. + real work is done in MYSQL_BIN_LOG::log_xa_prepare() */ - thd->transaction.xid_state.registered_for_binlog= true; return 0; } diff --git a/sql/sql_class.h b/sql/sql_class.h index bc87a5a..2e81cc2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1296,7 +1296,6 @@ typedef struct st_xid_state { That can cause inconsistencies (shoud be fixed?). */ bool is_binlogged; - bool registered_for_binlog; /** Check that XA transaction has an uncommitted work. Report an error