Merge lp:~vlad-lesin/percona-server/5.6-bugs-1268729-1268735 into lp:percona-server/5.6

Proposed by Vlad Lesin on 2014-02-04
Status: Merged
Approved by: Laurynas Biveinis on 2014-03-05
Approved revision: 544
Merged at revision: 554
Proposed branch: lp:~vlad-lesin/percona-server/5.6-bugs-1268729-1268735
Merge into: lp:percona-server/5.6
Diff against target: 180 lines (+126/-2)
4 files modified
mysql-test/suite/rpl/r/rpl_percona_gmvac_net_err.result (+33/-0)
mysql-test/suite/rpl/t/rpl_percona_gmvac_net_err.test (+67/-0)
sql-common/client.c (+6/-0)
sql/rpl_slave.cc (+20/-2)
To merge this branch: bzr merge lp:~vlad-lesin/percona-server/5.6-bugs-1268729-1268735
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) 2014-02-04 Approve on 2014-03-05
Review via email: mp+204786@code.launchpad.net

Description of the change

Bug #1268735 fixing is merged from 5.5.

The difference between 5.5 and this patches is the following:

      if (is_network_error(mysql_errno(mysql)))
      {
        mi->report(WARNING_LEVEL, mysql_errno(mysql),
                   "SET @master_heartbeat_period to master failed with error: %s",
                   mysql_error(mysql));
        mysql_free_result(mysql_store_result(mysql));
        goto network_err;
      }
- else if (!check_io_slave_killed(mi->io_thd, mi, NULL)) {
+ else {
        errmsg= "The slave I/O thread stops because SET @master_heartbeat_period "
          "on master failed.";
        err_code= ER_SLAVE_FATAL_ERROR;
        sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql));
        mysql_free_result(mysql_store_result(mysql));
        goto err;
      }

The initial code checked if the slave thread was killed in the case if there
was error in mysql_real_query(). To save this logic non-network error in
mysql_real_query() is treated as fatal error only if the slave thread was
not killed in 5.5. But as 5.6 upstream fix (see upstream revno: 2661.723.1)
does not contain this check it was decided do not include it in PS-5.6.

The fix for bug #1268729 merged from 5.5:
Slave I/O thread won't attempt to automatically reconnect to the master.

The fix is in including ER_NET_READ_INTERRUPTED error code to the set of
network related error codes in is_network_error() function.

The test case tests a couple of cases when get_master_version_and_clock()
fails due to ER_NET_READ_INTERRUPTED network error.

There are no big differences between 5.6 and 5.5 fixes.

http://jenkins.percona.com/view/PS%205.6/job/percona-server-5.6-param/498

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'mysql-test/suite/rpl/r/rpl_percona_gmvac_net_err.result'
2--- mysql-test/suite/rpl/r/rpl_percona_gmvac_net_err.result 1970-01-01 00:00:00 +0000
3+++ mysql-test/suite/rpl/r/rpl_percona_gmvac_net_err.result 2014-02-27 16:24:37 +0000
4@@ -0,0 +1,33 @@
5+include/master-slave.inc
6+Warnings:
7+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
8+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
9+[connection master]
10+call mtr.add_suppression("Slave I/O: Get master clock failed with error: , Error_code: 1159");
11+call mtr.add_suppression("Get master SERVER_ID failed with error: , Error_code: 1159");
12+call mtr.add_suppression("Slave I/O: SET @master_heartbeat_period to master failed with error: , Error_code: 1159");
13+call mtr.add_suppression("Slave I/O: Master command COM_REGISTER_SLAVE failed: .*");
14+call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
15+SET @debug_saved=@@global.debug;
16+include/stop_slave.inc
17+SET @@global.debug="+d,get_master_version.heartbeat.ER_NET_READ_INTERRUPTED";
18+START SLAVE;
19+include/wait_for_slave_io_to_start.inc
20+[log_grep.inc] file: pattern: The slave I/O thread stops because SET @master_heartbeat_period on master failed.
21+[log_grep.inc] lines: 0
22+include/stop_slave.inc
23+SET @@global.debug="+d,get_master_version.serverid.ER_NET_READ_INTERRUPTED";
24+START SLAVE;
25+include/wait_for_slave_io_to_start.inc
26+[log_grep.inc] file: pattern: fatal error is encountered when it try to get the value of SERVER_ID variable from master
27+[log_grep.inc] lines: 0
28+include/stop_slave.inc
29+SET @@global.debug="+d,get_master_version.timestamp.ER_NET_READ_INTERRUPTED";
30+START SLAVE;
31+include/wait_for_slave_io_to_start.inc
32+[log_grep.inc] file: pattern: "SELECT UNIX_TIMESTAMP.." failed on master, do not trust column
33+[log_grep.inc] lines: 0
34+include/stop_slave.inc
35+SET @@global.debug='';
36+include/start_slave.inc
37+include/rpl_end.inc
38
39=== added file 'mysql-test/suite/rpl/t/rpl_percona_gmvac_net_err.test'
40--- mysql-test/suite/rpl/t/rpl_percona_gmvac_net_err.test 1970-01-01 00:00:00 +0000
41+++ mysql-test/suite/rpl/t/rpl_percona_gmvac_net_err.test 2014-02-27 16:24:37 +0000
42@@ -0,0 +1,67 @@
43+# Bug #1268735:
44+# Slave I/O thread won't attempt to automatically reconnect to the master
45+# on ER_NET_READ_INTERRUPTED network error.
46+#
47+# The bug is in get_master_version_and_clock(). There are two places in this
48+# function where the bug takes place. The first one is getting master server id
49+# and the second one is getting master time. The error was injected to the code
50+# to test the bug fix.
51+
52+source include/master-slave.inc;
53+# The error injection works only with debug facilities.
54+source include/have_debug.inc;
55+source include/have_debug_sync.inc;
56+# The test is not supposed to have any binglog affairs.
57+# Hence it's enough it to run only with one binlog format
58+source include/have_binlog_format_mixed.inc;
59+
60+call mtr.add_suppression("Slave I/O: Get master clock failed with error: , Error_code: 1159");
61+call mtr.add_suppression("Get master SERVER_ID failed with error: , Error_code: 1159");
62+call mtr.add_suppression("Slave I/O: SET @master_heartbeat_period to master failed with error: , Error_code: 1159");
63+call mtr.add_suppression("Slave I/O: Master command COM_REGISTER_SLAVE failed: .*");
64+call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
65+
66+let log_file_full_path= `SELECT @@GLOBAL.log_error`;
67+if(!$log_file_full_path)
68+{
69+ # MySQL Server on windows is started with --console and thus
70+ # does not know the location of its .err log, use default location
71+ let log_file_full_path = $MYSQLTEST_VARDIR/log/mysqld.2.err;
72+}
73+
74+connection slave;
75+SET @debug_saved=@@global.debug;
76+
77+# i=1 for activating injected error during getting timestamp from master
78+# i=2 for activating injected error during getting server id from master
79+# i=3 for activating injected error during setting @master_heartbeat_period
80+let i=3;
81+
82+connection slave;
83+source include/stop_slave.inc;
84+let old_debug=`SELECT @@global.debug`;
85+
86+while($i)
87+{
88+ let debug_name=`SELECT CASE $i WHEN 1 THEN 'get_master_version.timestamp.ER_NET_READ_INTERRUPTED' WHEN 2 THEN 'get_master_version.serverid.ER_NET_READ_INTERRUPTED' WHEN 3 THEN 'get_master_version.heartbeat.ER_NET_READ_INTERRUPTED' END`;
89+
90+ # Stop slave and set debug variables
91+ eval SET @@global.debug="+d,$debug_name";
92+
93+ START SLAVE;
94+ # Crash if error during slave starting takes place
95+ let $rpl_allow_error= 0;
96+ source include/wait_for_slave_io_to_start.inc;
97+
98+ let grep_pattern=`SELECT CASE $i WHEN 1 THEN '"SELECT UNIX_TIMESTAMP.." failed on master, do not trust column' WHEN 2 THEN 'fatal error is encountered when it try to get the value of SERVER_ID variable from master' WHEN 3 THEN 'The slave I/O thread stops because SET @master_heartbeat_period on master failed.' END`;
99+
100+ source include/log_grep.inc;
101+
102+ source include/stop_slave.inc;
103+ dec $i;
104+}
105+
106+eval SET @@global.debug='$old_debug';
107+
108+source include/start_slave.inc;
109+source include/rpl_end.inc;
110
111=== modified file 'sql-common/client.c'
112--- sql-common/client.c 2013-12-05 17:23:10 +0000
113+++ sql-common/client.c 2014-02-27 16:24:37 +0000
114@@ -4153,6 +4153,12 @@
115 DBUG_ENTER("mysql_real_query");
116 DBUG_PRINT("enter",("handle: %p", mysql));
117 DBUG_PRINT("query",("Query = '%-.*s'", (int) length, query));
118+ DBUG_EXECUTE_IF("inject_ER_NET_READ_INTERRUPTED",
119+ {
120+ mysql->net.last_errno= ER_NET_READ_INTERRUPTED;
121+ DBUG_SET("-d,inject_ER_NET_READ_INTERRUPTED");
122+ DBUG_RETURN(1);
123+ });
124
125 if (mysql_send_query(mysql,query,length))
126 DBUG_RETURN(1);
127
128=== modified file 'sql/rpl_slave.cc'
129--- sql/rpl_slave.cc 2014-02-17 11:12:40 +0000
130+++ sql/rpl_slave.cc 2014-02-27 16:24:37 +0000
131@@ -1471,7 +1471,8 @@
132 errorno == CR_SERVER_GONE_ERROR ||
133 errorno == CR_SERVER_LOST ||
134 errorno == ER_CON_COUNT_ERROR ||
135- errorno == ER_SERVER_SHUTDOWN)
136+ errorno == ER_SERVER_SHUTDOWN ||
137+ errorno == ER_NET_READ_INTERRUPTED)
138 return TRUE;
139
140 return FALSE;
141@@ -1862,6 +1863,12 @@
142 };);
143
144 master_res= NULL;
145+ DBUG_EXECUTE_IF("get_master_version.timestamp.ER_NET_READ_INTERRUPTED",
146+ {
147+ DBUG_SET("+d,inject_ER_NET_READ_INTERRUPTED");
148+ DBUG_SET("-d,get_master_version.timestamp."
149+ "ER_NET_READ_INTERRUPTED");
150+ });
151 if (!mysql_real_query(mysql, STRING_WITH_LEN("SELECT UNIX_TIMESTAMP()")) &&
152 (master_res= mysql_store_result(mysql)) &&
153 (master_row= mysql_fetch_row(master_res)))
154@@ -1916,6 +1923,12 @@
155 };);
156 master_res= NULL;
157 master_row= NULL;
158+ DBUG_EXECUTE_IF("get_master_version.server_id.ER_NET_READ_INTERRUPTED",
159+ {
160+ DBUG_SET("+d,inject_ER_NET_READ_INTERRUPTED");
161+ DBUG_SET("-d,get_master_version.server_id."
162+ "ER_NET_READ_INTERRUPTED");
163+ });
164 if (!mysql_real_query(mysql,
165 STRING_WITH_LEN("SHOW VARIABLES LIKE 'SERVER_ID'")) &&
166 (master_res= mysql_store_result(mysql)) &&
167@@ -2105,7 +2118,12 @@
168 */
169 llstr((ulonglong) (mi->heartbeat_period*1000000000UL), llbuf);
170 sprintf(query, query_format, llbuf);
171-
172+ DBUG_EXECUTE_IF("get_master_version.heartbeat.ER_NET_READ_INTERRUPTED",
173+ {
174+ DBUG_SET("+d,inject_ER_NET_READ_INTERRUPTED");
175+ DBUG_SET("-d,get_master_version.heartbeat."
176+ "ER_NET_READ_INTERRUPTED");
177+ });
178 if (mysql_real_query(mysql, query, strlen(query)))
179 {
180 if (check_io_slave_killed(mi->info_thd, mi, NULL))

Subscribers

People subscribed via source and target branches