Commit 58c293f2 authored by Yuchen Pei's avatar Yuchen Pei

[demo][debug] spider: debugging MDEV-27438

parent 70e3c144
......@@ -77,7 +77,8 @@ if ($wait_for_all != 1)
while ($do_loop)
{
let $field_value= query_get_value($show_statement, $field, $rowno);
if (`SELECT '$field_value' $condition`)
# let $field_value= `select quote($field_value)`;
if (`SELECT "$field_value" $condition`)
{
let $found= 1;
let $do_loop= 0;
......
......@@ -54,7 +54,7 @@ SET DEBUG_SYNC= "now SIGNAL default_go";
connection default;
--enable_reconnect
--error 0,2013
--reap
--reap # sigabrt
--echo Must be tree logs in the list:
--source include/show_binary_logs.inc
......
......@@ -10,7 +10,11 @@ SET GLOBAL max_binlog_size= 4096;
SET GLOBAL innodb_flush_log_at_trx_commit= 1;
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
install soname 'ha_spider';
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_MYSOCK", DATABASE 'test',user 'root');
create table t2 (a INT PRIMARY KEY, b MEDIUMTEXT);
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Spider COMMENT="srv 'srv', table 't2'";
# MDEV-515 takes X-lock on the table for the first insert
# In that case, Concurrent DML will get blocked
INSERT INTO t1 VALUES(100, "MDEV-515");
......@@ -44,7 +48,7 @@ EOF
SET DEBUG_SYNC= "now SIGNAL con1_cont";
connection con1;
--error 2006,2013
reap;
reap; # sigabrt
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart-binlog_mdev342.test
......
......@@ -63,6 +63,7 @@ SELECT @@global.gtid_binlog_state;
#
# Server restart
#
# sigabrt somewhere here
--let $restart_parameters= --init-rpl-role=SLAVE --sync-binlog=1 --log-warnings=3
--source include/start_mysqld.inc
......
......@@ -94,6 +94,7 @@ SELECT @@global.gtid_binlog_state;
--error 1
--exec $MYSQLD_LAST_CMD --init-rpl-role=SLAVE >> $MYSQLTEST_VARDIR/log/mysqld.1.err 2>&1
# somewhere below: sigabrt
--echo # Normal restart
--source include/start_mysqld.inc
......
......@@ -16,11 +16,19 @@
SET GLOBAL max_binlog_size= 4096;
SET GLOBAL innodb_flush_log_at_trx_commit= 1;
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
install soname 'ha_spider';
set spider_same_server_link=1;
set global spider_same_server_link=1;
# set spider_internal_xa=1;
# set global spider_internal_xa=1;
--let $SOCKET= `SELECT @@global.socket`
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$SOCKET", DATABASE 'test',user 'root');
CREATE TABLE t2 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Spider COMMENT="srv 'srv', table 't2'";
# Insert some data to force a couple binlog rotations (3), so we get some
# normal binlog checkpoints before starting the test.
INSERT INTO t1 VALUES (100, REPEAT("x", 4100));
# SHOW BINLOG EVENTS IN "master-bin.000002";
# Wait for the master-bin.000002 binlog checkpoint to appear.
--let $wait_for_all= 0
--let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000002"
......@@ -56,6 +64,8 @@ INSERT INTO t1 VALUES (102, REPEAT("x", 4100));
# master-bin.000006.
connect(con1,localhost,root,,);
# todo: try setting global var in default conn instead
# set spider_same_server_link=1;
# First wait after prepare and before write to binlog.
SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con1_wait WAIT_FOR con1_cont";
# Then complete InnoDB commit in memory (but not commit checkpoint / write to
......@@ -67,6 +77,7 @@ connection default;
SET DEBUG_SYNC= "now WAIT_FOR con1_wait";
connect(con2,localhost,root,,);
# set spider_same_server_link=1;
SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con2_wait WAIT_FOR con2_cont";
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con2_ready WAIT_FOR _ever";
send INSERT INTO t1 VALUES (2, NULL);
......@@ -75,6 +86,7 @@ connection default;
SET DEBUG_SYNC= "now WAIT_FOR con2_wait";
connect(con3,localhost,root,,);
# set spider_same_server_link=1;
SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con3_wait WAIT_FOR con3_cont";
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con3_ready WAIT_FOR _ever";
send INSERT INTO t1 VALUES (3, REPEAT("x", 4100));
......@@ -83,6 +95,7 @@ connection default;
SET DEBUG_SYNC= "now WAIT_FOR con3_wait";
connect(con4,localhost,root,,);
# set spider_same_server_link=1;
SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con4_wait WAIT_FOR con4_cont";
SET SESSION debug_dbug="+d,crash_commit_after_log";
send INSERT INTO t1 VALUES (4, NULL);
......@@ -114,164 +127,167 @@ SET DEBUG_SYNC= "now WAIT_FOR con3_ready";
PURGE BINARY LOGS TO "master-bin.000006";
--source include/show_binary_logs.inc
# Now crash the server with one more transaction in prepared state.
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
wait-binlog_xa_recover.test
EOF
--error 0,2006,2013
SET DEBUG_SYNC= "now SIGNAL con4_cont";
connection con4;
--error 2006,2013
reap;
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart-group_commit_binlog_pos.test
EOF
connection default;
--enable_reconnect
--source include/wait_until_connected_again.inc
# Check that all transactions are recovered.
SELECT a FROM t1 ORDER BY a;
--echo Test that with multiple binlog checkpoints, recovery starts from the last one.
SET GLOBAL max_binlog_size= 4096;
SET GLOBAL innodb_flush_log_at_trx_commit= 1;
RESET MASTER;
# Rotate to binlog master-bin.000003 while delaying binlog checkpoints.
# So we get multiple binlog checkpoints in master-bin.000003.
# Then complete the checkpoints, crash, and check that we only scan
# the necessary binlog file (ie. that we use the _last_ checkpoint).
connect(con10,localhost,root,,);
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con10_ready WAIT_FOR con10_cont";
send INSERT INTO t1 VALUES (10, REPEAT("x", 4100));
connection default;
SET DEBUG_SYNC= "now WAIT_FOR con10_ready";
connect(con11,localhost,root,,);
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con11_ready WAIT_FOR con11_cont";
send INSERT INTO t1 VALUES (11, REPEAT("x", 4100));
connection default;
SET DEBUG_SYNC= "now WAIT_FOR con11_ready";
connect(con12,localhost,root,,);
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con12_ready WAIT_FOR con12_cont";
send INSERT INTO t1 VALUES (12, REPEAT("x", 4100));
connection default;
SET DEBUG_SYNC= "now WAIT_FOR con12_ready";
INSERT INTO t1 VALUES (13, NULL);
--source include/show_binary_logs.inc
--let $binlog_file= master-bin.000004
--let $binlog_start= 4
--source include/show_binlog_events.inc
SET DEBUG_SYNC= "now SIGNAL con10_cont";
connection con10;
reap;
connection default;
# We need to sync the test case with the background processing of the
# commit checkpoint, otherwise we get nondeterministic results.
let $wait_condition= select count(*) = 1 from performance_schema.threads where processlist_state = "Waiting for background binlog tasks";
--source include/wait_condition.inc
SET DEBUG_SYNC= "now SIGNAL con12_cont";
connection con12;
reap;
connection default;
SET DEBUG_SYNC= "now SIGNAL con11_cont";
connection con11;
reap;
connection default;
# Wait for the last (master-bin.000004) binlog checkpoint to appear.
--let $wait_for_all= 0
--let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000004"
--let $field= Info
--let $condition= = "master-bin.000004"
--source include/wait_show_condition.inc
--echo Now crash the server
# It is not too easy to test XA recovery, as it runs early during server
# startup, before any connections can be made.
# What we do is set a DBUG error insert which will crash if XA recovery
# starts from any other binlog than master-bin.000004 (check the file
# binlog_xa_recover-master.opt). Then we will fail here if XA recovery
# would start from the wrong place.
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
wait-binlog_xa_recover.test
EOF
SET SESSION debug_dbug="+d,crash_commit_after_log";
--error 2006,2013
INSERT INTO t1 VALUES (14, NULL);
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart-group_commit_binlog_pos.test
EOF
connection default;
--enable_reconnect
--source include/wait_until_connected_again.inc
# Check that all transactions are recovered.
SELECT a FROM t1 ORDER BY a;
--echo *** Check that recovery works if we crashed early during rotate, before
--echo *** binlog checkpoint event could be written.
SET GLOBAL max_binlog_size= 4096;
SET GLOBAL innodb_flush_log_at_trx_commit= 1;
RESET MASTER;
# We need some initial data to reach binlog master-bin.000004. Otherwise
# crash recovery fails due to the error insert used for previous test.
INSERT INTO t1 VALUES (21, REPEAT("x", 4100));
INSERT INTO t1 VALUES (22, REPEAT("x", 4100));
# Wait for the master-bin.000003 binlog checkpoint to appear.
--let $wait_for_all= 0
--let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000003"
--let $field= Info
--let $condition= = "master-bin.000003"
--source include/wait_show_condition.inc
INSERT INTO t1 VALUES (23, REPEAT("x", 4100));
# Wait for the last (master-bin.000004) binlog checkpoint to appear.
--let $wait_for_all= 0
--let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000004"
--let $field= Info
--let $condition= = "master-bin.000004"
--source include/wait_show_condition.inc
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
wait-binlog_xa_recover.test
EOF
SET SESSION debug_dbug="+d,crash_before_write_checkpoint_event";
--error 2006,2013
INSERT INTO t1 VALUES (24, REPEAT("x", 4100));
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart-group_commit_binlog_pos.test
EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
# Check that all transactions are recovered.
SELECT a FROM t1 ORDER BY a;
--source include/show_binary_logs.inc
--let $binlog_file= master-bin.000004
--let $binlog_start= 4
--source include/show_binlog_events.inc
# Cleanup
connection default;
DROP TABLE t1;
# # Now crash the server with one more transaction in prepared state.
# --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
# wait-binlog_xa_recover.test
# EOF
# --error 0,2006,2013
# SET DEBUG_SYNC= "now SIGNAL con4_cont";
# connection con4;
# --error 2006,2013
# reap; # sigabrt
# --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
# restart-group_commit_binlog_pos.test
# EOF
# connection default;
# --enable_reconnect
# --source include/wait_until_connected_again.inc
# # Check that all transactions are recovered.
# SELECT a FROM t1 ORDER BY a;
# --echo Test that with multiple binlog checkpoints, recovery starts from the last one.
# SET GLOBAL max_binlog_size= 4096;
# SET GLOBAL innodb_flush_log_at_trx_commit= 1;
# RESET MASTER;
# # Rotate to binlog master-bin.000003 while delaying binlog checkpoints.
# # So we get multiple binlog checkpoints in master-bin.000003.
# # Then complete the checkpoints, crash, and check that we only scan
# # the necessary binlog file (ie. that we use the _last_ checkpoint).
# connect(con10,localhost,root,,);
# set spider_same_server_link=1;
# SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con10_ready WAIT_FOR con10_cont";
# send INSERT INTO t1 VALUES (10, REPEAT("x", 4100));
# connection default;
# SET DEBUG_SYNC= "now WAIT_FOR con10_ready";
# connect(con11,localhost,root,,);
# set spider_same_server_link=1;
# SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con11_ready WAIT_FOR con11_cont";
# send INSERT INTO t1 VALUES (11, REPEAT("x", 4100));
# connection default;
# SET DEBUG_SYNC= "now WAIT_FOR con11_ready";
# connect(con12,localhost,root,,);
# set spider_same_server_link=1;
# SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con12_ready WAIT_FOR con12_cont";
# send INSERT INTO t1 VALUES (12, REPEAT("x", 4100));
# connection default;
# SET DEBUG_SYNC= "now WAIT_FOR con12_ready";
# INSERT INTO t1 VALUES (13, NULL);
# --source include/show_binary_logs.inc
# --let $binlog_file= master-bin.000004
# --let $binlog_start= 4
# --source include/show_binlog_events.inc
# SET DEBUG_SYNC= "now SIGNAL con10_cont";
# connection con10;
# reap;
# connection default;
# # We need to sync the test case with the background processing of the
# # commit checkpoint, otherwise we get nondeterministic results.
# let $wait_condition= select count(*) = 1 from performance_schema.threads where processlist_state = "Waiting for background binlog tasks";
# --source include/wait_condition.inc
# SET DEBUG_SYNC= "now SIGNAL con12_cont";
# connection con12;
# reap;
# connection default;
# SET DEBUG_SYNC= "now SIGNAL con11_cont";
# connection con11;
# reap;
# connection default;
# # Wait for the last (master-bin.000004) binlog checkpoint to appear.
# --let $wait_for_all= 0
# --let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000004"
# --let $field= Info
# --let $condition= = "master-bin.000004"
# --source include/wait_show_condition.inc
# --echo Now crash the server
# # It is not too easy to test XA recovery, as it runs early during server
# # startup, before any connections can be made.
# # What we do is set a DBUG error insert which will crash if XA recovery
# # starts from any other binlog than master-bin.000004 (check the file
# # binlog_xa_recover-master.opt). Then we will fail here if XA recovery
# # would start from the wrong place.
# --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
# wait-binlog_xa_recover.test
# EOF
# SET SESSION debug_dbug="+d,crash_commit_after_log";
# --error 2006,2013
# INSERT INTO t1 VALUES (14, NULL);
# --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
# restart-group_commit_binlog_pos.test
# EOF
# connection default;
# --enable_reconnect
# --source include/wait_until_connected_again.inc
# # Check that all transactions are recovered.
# SELECT a FROM t1 ORDER BY a;
# --echo *** Check that recovery works if we crashed early during rotate, before
# --echo *** binlog checkpoint event could be written.
# SET GLOBAL max_binlog_size= 4096;
# SET GLOBAL innodb_flush_log_at_trx_commit= 1;
# RESET MASTER;
# # We need some initial data to reach binlog master-bin.000004. Otherwise
# # crash recovery fails due to the error insert used for previous test.
# INSERT INTO t1 VALUES (21, REPEAT("x", 4100));
# INSERT INTO t1 VALUES (22, REPEAT("x", 4100));
# # Wait for the master-bin.000003 binlog checkpoint to appear.
# --let $wait_for_all= 0
# --let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000003"
# --let $field= Info
# --let $condition= = "master-bin.000003"
# --source include/wait_show_condition.inc
# INSERT INTO t1 VALUES (23, REPEAT("x", 4100));
# # Wait for the last (master-bin.000004) binlog checkpoint to appear.
# --let $wait_for_all= 0
# --let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000004"
# --let $field= Info
# --let $condition= = "master-bin.000004"
# --source include/wait_show_condition.inc
# --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
# wait-binlog_xa_recover.test
# EOF
# SET SESSION debug_dbug="+d,crash_before_write_checkpoint_event";
# --error 2006,2013
# INSERT INTO t1 VALUES (24, REPEAT("x", 4100));
# --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
# restart-group_commit_binlog_pos.test
# EOF
# --enable_reconnect
# --source include/wait_until_connected_again.inc
# # Check that all transactions are recovered.
# SELECT a FROM t1 ORDER BY a;
# --source include/show_binary_logs.inc
# --let $binlog_file= master-bin.000004
# --let $binlog_start= 4
# --source include/show_binlog_events.inc
# # Cleanup
# connection default;
# DROP TABLE t1;
......@@ -2609,6 +2609,7 @@ static void xarecover_do_commit_or_rollback(handlerton *hton,
else
x= *member->full_xid;
// abort();
rc= xarecover_decide_to_commit(member, ptr_commit_max) ?
hton->commit_by_xid(hton, &x) : hton->rollback_by_xid(hton, &x);
......
......@@ -11680,11 +11680,13 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name,
{
if (!binlog_checkpoint_found)
break;
DBUG_EXECUTE_IF("xa_recover_expect_master_bin_000004",
if (0 != strcmp("./master-bin.000004", binlog_checkpoint_name) &&
0 != strcmp(".\\master-bin.000004", binlog_checkpoint_name))
DBUG_SUICIDE();
);
/*
DBUG_EXECUTE_IF("xa_recover_expect_master_bin_000004",
if (0 != strcmp("./master-bin.000004", binlog_checkpoint_name) &&
0 != strcmp(".\\master-bin.000004", binlog_checkpoint_name))
DBUG_SUICIDE();
);
*/
if (find_log_pos(linfo, binlog_checkpoint_name, 1))
{
sql_print_error("Binlog file '%s' not found in binlog index, needed "
......
......@@ -3287,6 +3287,9 @@ int spider_xa_commit_by_xid(
THD* thd = current_thd;
DBUG_ENTER("spider_xa_commit_by_xid");
/*
abort();
*/
if (!(trx = spider_get_trx(thd, TRUE, &error_num)))
goto error_get_trx;
......@@ -3309,6 +3312,9 @@ int spider_xa_rollback_by_xid(
THD* thd = current_thd;
DBUG_ENTER("spider_xa_rollback_by_xid");
/*
abort();
*/
if (!(trx = spider_get_trx(thd, TRUE, &error_num)))
goto error_get_trx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment