diff options
author | unknown <Dao-Gang.Qu@sun.com> | 2009-07-16 14:56:43 +0800 |
---|---|---|
committer | unknown <Dao-Gang.Qu@sun.com> | 2009-07-16 14:56:43 +0800 |
commit | aa4b8939a0ccc47e40e97af10b151f139e887b65 (patch) | |
tree | fd56e1a55c360340d0696cfda82bf3f850a028ff /mysql-test/suite/rpl | |
parent | 5f9440d2a628b8f78ce4f172a2028f2749800639 (diff) | |
download | mariadb-git-aa4b8939a0ccc47e40e97af10b151f139e887b65.tar.gz |
Bug #45214 get_master_version_and_clock does not report error when queries fail
The "get_master_version_and_clock(...)" function in sql/slave.cc ignores
error and passes directly when queries fail, or queries succeed
but the result retrieved is empty.
The "get_master_version_and_clock(...)" function should try to reconnect master
if queries fail because of transient network problems, and fail otherwise.
The I/O thread should print a warning if the some system variables do not
exist on master (very old master)
mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test:
Added test file for bug #45214
mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result:
Added test result for bug #45214
mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test:
Added test file for bug #45214
sql/slave.cc:
The 'is_network_error()' function is added for checking if the error is caused by network.
Added a new return value (2) to 'get_master_version_and_clock()' function result set
to indicate transient network errors when queries fail, and the caller should
try to reconnect in this case.
Diffstat (limited to 'mysql-test/suite/rpl')
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result | 40 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test | 60 |
2 files changed, 100 insertions, 0 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result b/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result new file mode 100644 index 00000000000..263896b884a --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result @@ -0,0 +1,40 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +SELECT IS_FREE_LOCK("debug_lock.before_get_UNIX_TIMESTAMP"); +IS_FREE_LOCK("debug_lock.before_get_UNIX_TIMESTAMP") +1 +SELECT GET_LOCK("debug_lock.before_get_UNIX_TIMESTAMP", 1000); +GET_LOCK("debug_lock.before_get_UNIX_TIMESTAMP", 1000) +1 +set global debug= 'd,debug_lock.before_get_UNIX_TIMESTAMP'; +stop slave; +start slave; +SELECT RELEASE_LOCK("debug_lock.before_get_UNIX_TIMESTAMP"); +RELEASE_LOCK("debug_lock.before_get_UNIX_TIMESTAMP") +1 +Slave_IO_Errno= 2013 +SELECT IS_FREE_LOCK("debug_lock.before_get_SERVER_ID"); +IS_FREE_LOCK("debug_lock.before_get_SERVER_ID") +1 +SELECT GET_LOCK("debug_lock.before_get_SERVER_ID", 1000); +GET_LOCK("debug_lock.before_get_SERVER_ID", 1000) +1 +set global debug= 'd,debug_lock.before_get_SERVER_ID'; +stop slave; +start slave; +SELECT RELEASE_LOCK("debug_lock.before_get_SERVER_ID"); +RELEASE_LOCK("debug_lock.before_get_SERVER_ID") +1 +Slave_IO_Errno= 2013 +set global debug= ''; +reset master; +include/stop_slave.inc +change master to master_port=SLAVE_PORT; +start slave; +*** must be having the replicate-same-server-id IO thread error *** +Slave_IO_Errno= 1593 +Slave_IO_Error= Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it). diff --git a/mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test b/mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test new file mode 100644 index 00000000000..3084bfc32fc --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test @@ -0,0 +1,60 @@ +# +# BUG#45214 +# This test verifies if the slave I/O tread tries to reconnect to +# master when it tries to get the values of the UNIX_TIMESTAMP, SERVER_ID, +# COLLATION_SERVER and TIME_ZONE from master under network disconnection. +# The COLLATION_SERVER and TIME_ZONE are got only on master server version 4. +# So they can't be verified by test case here. +# Finish the following tests by calling its common test script: +# extra/rpl_tests/rpl_get_master_version_and_clock.test. +# And meanwhile this test checks that the slave I/O thread refuses to start if slave +# and master have the same server id (because this is a useless setup, +# and otherwise SHOW SLAVE STATUS shows progress but all queries are +# ignored, which has caught our customers), unless +# --replicate-same-server-id. +# + +source include/master-slave.inc; + +#Test case 1: Try to get the value of the UNIX_TIMESTAMP from master under network disconnection +connection slave; +let $debug_saved= `select @@global.debug`; + +let $debug_lock= "debug_lock.before_get_UNIX_TIMESTAMP"; +eval SELECT IS_FREE_LOCK($debug_lock); +eval SELECT GET_LOCK($debug_lock, 1000); + +set global debug= 'd,debug_lock.before_get_UNIX_TIMESTAMP'; +source extra/rpl_tests/rpl_get_master_version_and_clock.test; + +#Test case 2: Try to get the value of the SERVER_ID from master under network disconnection +connection slave; +let $debug_lock= "debug_lock.before_get_SERVER_ID"; +eval SELECT IS_FREE_LOCK($debug_lock); +eval SELECT GET_LOCK($debug_lock, 1000); + +set global debug= 'd,debug_lock.before_get_SERVER_ID'; +source extra/rpl_tests/rpl_get_master_version_and_clock.test; + +eval set global debug= '$debug_saved'; + +#Test case 3: This test checks that the slave I/O thread refuses to start +#if slave and master have the same server id. +connection slave; +reset master; +# replicate ourselves +source include/stop_slave.inc; +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval change master to master_port=$SLAVE_MYPORT; +start slave; + +let $slave_param= Last_IO_Errno; +let $slave_param_value= 1593; +source include/wait_for_slave_param.inc; +--echo *** must be having the replicate-same-server-id IO thread error *** +let $last_io_errno= query_get_value("show slave status", Last_IO_Errno, 1); +let $last_io_error= query_get_value("show slave status", Last_IO_Error, 1); +echo Slave_IO_Errno= $last_io_errno; +echo Slave_IO_Error= $last_io_error; + +# End of tests |