# ==== Purpose ==== # # This script tests server behavior when a crash occurs during the # execution of `XA COMMIT`, just before the transaction is committed at the # RUN_HOOK before_commit. # # ==== Requirements ==== # # Pre-conditions: # PC1. GR single-primary topology with 3 servers. # # ==== Implementation ==== # # 1. Setup scenario: setup GR, create table and insert some records. # 2. Start and execute an XA transaction containing an insert until before `XA COMMIT`. # 3. Take the `GTID_EXECUTED` state. # 4. Crash the primary during `XA COMMIT` execution before committing at the RUN_HOOK before_commit # # 5. Restart server 1 (former primary) and check: # a. The `XA COMMIT` is absent in the binary log. # b. There aren't any pending XA transaction listed in the output of `XA # RECOVER`. # c. The table has not been updated. # 6. On server 2: # a. The table has been updated. # 7. Re-join server 1 (former primary) to the group. # # ==== References ==== # #binlog_xa_commit_failure.test #gr_xa_commit_failure_before_commit_engines.test # --source include/not_valgrind.inc --source include/have_debug.inc --source include/have_debug_sync.inc --source include/have_group_replication_plugin.inc --let $rpl_group_replication_single_primary_mode =1 --let $rpl_skip_group_replication_start = 1 --let $rpl_server_count = 3 --source include/group_replication.inc # 1. Setup scenario: setup GR, create table and insert some records. # --let $rpl_connection_name = server1 --source include/rpl_connection.inc --let $xid_data = xid1 --let $xid = `SELECT CONCAT("X'", LOWER(HEX('$xid_data')), "',X'',1")` --source extra/xa_crash_safe_tests/setup.inc # 2. Start and execute an XA transaction containing an insert until before # `XA COMMIT`. # --connect(con1, localhost, root,,) --connection con1 --eval XA START $xid INSERT INTO t1 VALUES (1); --eval XA END $xid --eval XA PREPARE $xid # 3. Take the `GTID_EXECUTED` state. # --let $rpl_connection_name = server1 --source include/rpl_connection.inc --source include/rpl_sync.inc --let $before_gtid_executed = `SELECT @@GLOBAL.gtid_executed` # 4. Crash the primary during `XA COMMIT` execution before committing in RUN_HOOK # # SET SESSION DEBUG= '+d,simulate_failure_in_before_commit_hook'; --error ER_RUN_HOOK_ERROR --eval XA COMMIT $xid; --source include/kill_mysqld.inc #--source extra/xa_crash_safe_tests/cleanup_connection.inc --let $rpl_connection_name = server2 --source include/rpl_connection.inc --let $group_replication_number_of_members = 2 --source include/gr_wait_for_number_of_members.inc # 5. Restart server 1 (former primary) and check: # --let $restart_parameters = restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group_replication_group_name=$_group_replication_group_name --group_replication_start_on_boot=OFF --group_replication_single_primary_mode=TRUE --group_replication_enforce_update_everywhere_checks=FALSE --replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $_group_replication_group_name GROUP_REPLICATION_GROUP_NAME --source include/start_mysqld.inc --let $rpl_server_number = 1 --source include/rpl_reconnect.inc --let $rpl_connection_name = server1 --source include/rpl_connection.inc # 6. On server 2, check: # --let $rpl_connection_name = server2 --source include/rpl_connection.inc --let $wait_condition = SELECT @@GLOBAL.gtid_executed <> "$before_gtid_executed" --source include/wait_condition.inc --let $commit_gtid_executed = `SELECT @@GLOBAL.gtid_executed` # 6.a. The table has been updated. # --let $expected_row_count = 2 --source extra/xa_crash_safe_tests/assert_row_count.inc # 7. Re-join server 1 (former primary) to the group. # --let $rpl_connection_name = server1 --source include/rpl_connection.inc --let $group_replication_group_name = $_group_replication_group_name --source include/start_group_replication.inc --source include/gr_find_a_primary.inc --connection $group_replication_primary_connection_out_var --let $group_replication_number_of_members = 3 --source include/gr_wait_for_number_of_members.inc --let $wait_condition = SELECT @@GLOBAL.gtid_executed <> "$commit_gtid_executed" --source include/wait_condition.inc DROP TABLE t1; --let $rpl_connection_name = server2 --source include/rpl_connection.inc --source include/restore_sysvars.inc --let $rpl_connection_name = server3 --source include/rpl_connection.inc --source include/restore_sysvars.inc --source include/group_replication_end.inc