summaryrefslogtreecommitdiff
path: root/mysql-test/suite/large_tests
diff options
context:
space:
mode:
authorAndrei Elkin <aelkin@mysql.com>2010-02-28 19:31:46 +0200
committerAndrei Elkin <aelkin@mysql.com>2010-02-28 19:31:46 +0200
commit1faafbb0475c538b1348789a86cd6455ee24d37d (patch)
treea1279a0a8e675f90f12da9b7a12452d5dbb16767 /mysql-test/suite/large_tests
parent827a0d7cb4e825c7b7af6e0be7f0c82c4741ee6a (diff)
downloadmariadb-git-1faafbb0475c538b1348789a86cd6455ee24d37d.tar.gz
Bug #50296 Slave reconnects earlier than the prescribed slave_net_timeout value
There was auto-reconnecting by slave earlier than a prescribed by slave_net_timeout value. The issue happened on 64bit solaris that spotted rather incorrect casting of the ulong slave_net_timeout into the uint of mysql.options.read_timeout. Notice, that there is no reason for slave_net_timeout to be of type of ulong. Since it's primarily passed as arg to mysql_options the type can be made as uint to avoid all conversion hassles. That's what the fixes are made. A "side" effect of the patch is a new value for the max of slave_net_timeout to be the max of the unsigned int type (therefore to vary across platforms). Note, a regression test can't be made to run reliably without making it to last over some 20 secs. That's why it is placed in suite/large_tests. mysql-test/suite/large_tests/r/rpl_slave_net_timeout.result: the new test results. mysql-test/suite/large_tests/t/rpl_slave_net_timeout-slave.opt: Initialization of the option that yields slave_net_timeout's default. sql/mysql_priv.h: changing type for slave_net_timeout from ulong to uint sql/mysqld.cc: changing type for slave_net_timeout from ulong to uint sql/sys_vars.cc: Refining the max value for slave_net_timeout to be as the max for uint type.
Diffstat (limited to 'mysql-test/suite/large_tests')
-rw-r--r--mysql-test/suite/large_tests/r/rpl_slave_net_timeout.result25
-rw-r--r--mysql-test/suite/large_tests/t/rpl_slave_net_timeout-slave.opt1
-rw-r--r--mysql-test/suite/large_tests/t/rpl_slave_net_timeout.test81
3 files changed, 107 insertions, 0 deletions
diff --git a/mysql-test/suite/large_tests/r/rpl_slave_net_timeout.result b/mysql-test/suite/large_tests/r/rpl_slave_net_timeout.result
new file mode 100644
index 00000000000..526221fcb50
--- /dev/null
+++ b/mysql-test/suite/large_tests/r/rpl_slave_net_timeout.result
@@ -0,0 +1,25 @@
+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;
+set @save_general_log = @@global.general_log;
+set @save_log_output = @@global.log_output;
+set @save_slave_net_timeout = @@global.slave_net_timeout;
+set @@global.general_log = ON;
+set @@global.log_output = 'table,file';
+include/stop_slave.inc
+set @@global.slave_net_timeout = @@global.net_read_timeout * 2;
+change master to master_host = '127.0.0.1',master_port = 13020,
+master_user = 'root', master_heartbeat_period = 0;
+include/start_slave.inc
+include/stop_slave.inc
+select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time desc limit 1 into @ts_last;
+select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time asc limit 1 into @ts_prev;
+select @result as 'Must be 1';
+Must be 1
+1
+set @@global.general_log = @save_general_log;
+set @@global.log_output = @save_log_output;
+set @@global.slave_net_timeout = @save_slave_net_timeout;
diff --git a/mysql-test/suite/large_tests/t/rpl_slave_net_timeout-slave.opt b/mysql-test/suite/large_tests/t/rpl_slave_net_timeout-slave.opt
new file mode 100644
index 00000000000..281566c9ad9
--- /dev/null
+++ b/mysql-test/suite/large_tests/t/rpl_slave_net_timeout-slave.opt
@@ -0,0 +1 @@
+--net_read_timeout=5
diff --git a/mysql-test/suite/large_tests/t/rpl_slave_net_timeout.test b/mysql-test/suite/large_tests/t/rpl_slave_net_timeout.test
new file mode 100644
index 00000000000..7712c054258
--- /dev/null
+++ b/mysql-test/suite/large_tests/t/rpl_slave_net_timeout.test
@@ -0,0 +1,81 @@
+#
+# Testing reconnecting by slave as specified by `slave_net_timeout'
+#
+# Bug #50296 Slave reconnects earlier than the prescribed slave_net_timeout value
+#
+--source include/have_csv.inc
+--source include/master-slave.inc
+
+
+# save global env
+connection master;
+set @save_general_log = @@global.general_log;
+set @save_log_output = @@global.log_output;
+
+connection slave;
+set @save_slave_net_timeout = @@global.slave_net_timeout;
+
+connection master;
+set @@global.general_log = ON;
+set @@global.log_output = 'table,file';
+
+connection slave;
+--source include/stop_slave.inc
+--disable_warnings
+set @@global.slave_net_timeout = @@global.net_read_timeout * 2;
+--enable_warnings
+let $idle_time=`select @@global.slave_net_timeout * 2`;
+
+#
+# if heartbeat is disabled then reconnecting to the idle master
+# should happen with `slave_net_timeout' period.
+# Since it's the real time that is measured, `slave_net_timeout'
+# merely guarantees that reconnecting can *not* happen earlier of a value specified.
+# That is there can't an exact estimate for how many time it will happen.
+#
+# The following lines verify that having idle master
+# for more than 2 * slave_net_timeout seconds and
+# slave.net_read_timeout < slave_net_timeout
+# won't cause reconnecting by the slave within at least
+# slave_net_timeout interval.
+
+eval change master to master_host = '127.0.0.1',master_port = $MASTER_MYPORT,
+master_user = 'root', master_heartbeat_period = 0;
+
+let $slave_net_timeout = `select @@global.slave_net_timeout`;
+
+--source include/start_slave.inc
+
+--disable_query_log
+--disable_result_log
+eval select 'master is idle for ', sleep($idle_time);
+--enable_result_log
+--enable_query_log
+
+--source include/stop_slave.inc
+
+# querying general-log
+
+connection master;
+
+# In particular the last reconnection timestamp must be greater or equal to
+# the previous one + slave_net_timeout
+
+select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time desc limit 1 into @ts_last;
+select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time asc limit 1 into @ts_prev;
+
+--disable_query_log
+eval select time_to_sec(@ts_last) - $slave_net_timeout >= time_to_sec(@ts_prev) into @result;
+--enable_query_log
+
+select @result as 'Must be 1';
+
+# cleanup
+
+# restore global env
+connection master;
+set @@global.general_log = @save_general_log;
+set @@global.log_output = @save_log_output;
+connection slave;
+set @@global.slave_net_timeout = @save_slave_net_timeout;
+