Merge lp:~gl-az/percona-server/ST-29716-bug1135097-5.6 into lp:percona-server/5.6

Proposed by George Ormond Lorch III
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 322
Proposed branch: lp:~gl-az/percona-server/ST-29716-bug1135097-5.6
Merge into: lp:percona-server/5.6
Diff against target: 92 lines (+45/-10)
5 files modified
Percona-Server/mysql-test/suite/rpl/r/rpl_bug68490.result (+11/-0)
Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490-master.opt (+1/-0)
Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490-slave.opt (+2/-0)
Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490.test (+21/-0)
Percona-Server/sql/rpl_slave.cc (+10/-10)
To merge this branch: bzr merge lp:~gl-az/percona-server/ST-29716-bug1135097-5.6
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Review via email: mp+152257@code.launchpad.net

Commit message

Fix for upstream bugs.mysql.com/bug.php?id=68490 and bugs.launchpad.net/percona-server/+bug/1135097

When reconnecting to the master, the mysql client library in sql-common/client.c::mysql_reconnect creates a new 'tmp' MYSQL* with all default values (overwriting the MYSQL::net.max_packet_size with default). It then copies the contents of the tmp back into the passed in MYSQL*.

This causes issues with the slave connection when reconnecting because: 1) The code in handle_slave_io(...) is not setting the mysql->option.max_allowed_packet but directly manipulating the mysql->net.max_packet_size which gets reset when the connection is recreated as described above, and 2) the mysql->options.max_allowed_packet is being set in the top of handle_slave_io(...) and not in connect_to_master(...) where all other client options are being set for the connection and thus is not always properly set to the correct value depending on the reason for reconnecting.

The fix is somewhat simple, in sql/slave.cc, moves lines 4017-4027 from handle_slave_io to line 6640 and change:
  mysql->net.max_packet_size= thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER;
to
  mysql->options.max_allowed_packet= thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER;

Added test suite/rpl/t/rpl_packet_bug68490.test

Description of the change

Fix for upstream bugs.mysql.com/bug.php?id=68490 and bugs.launchpad.net/percona-server/+bug/1135097

When reconnecting to the master, the mysql client library in sql-common/client.c::mysql_reconnect creates a new 'tmp' MYSQL* with all default values (overwriting the MYSQL::net.max_packet_size with default). It then copies the contents of the tmp back into the passed in MYSQL*.

This causes issues with the slave connection when reconnecting because: 1) The code in handle_slave_io(...) is not setting the mysql->option.max_allowed_packet but directly manipulating the mysql->net.max_packet_size which gets reset when the connection is recreated as described above, and 2) the mysql->options.max_allowed_packet is being set in the top of handle_slave_io(...) and not in connect_to_master(...) where all other client options are being set for the connection and thus is not always properly set to the correct value depending on the reason for reconnecting.

The fix is somewhat simple, in sql/slave.cc, moves lines 4017-4027 from handle_slave_io to line 6640 and change:
  mysql->net.max_packet_size= thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER;
to
  mysql->options.max_allowed_packet= thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER;

Added test suite/rpl/t/rpl_packet_bug68490.test

To post a comment you must log in.
Revision history for this message
George Ormond Lorch III (gl-az) wrote :
Revision history for this message
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Percona-Server/mysql-test/suite/rpl/r/rpl_bug68490.result'
2--- Percona-Server/mysql-test/suite/rpl/r/rpl_bug68490.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/suite/rpl/r/rpl_bug68490.result 2013-03-07 19:06:28 +0000
4@@ -0,0 +1,11 @@
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 see the MySQL Manual for more about this issue and possible alternatives.
9+[connection master]
10+DROP TABLE IF EXISTS t1;
11+CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, payload MEDIUMBLOB NOT NULL);
12+include/rpl_restart_server.inc [server_number=1]
13+INSERT INTO t1(payload) VALUES(REPEAT('a',1468872));
14+DROP TABLE t1;
15+include/rpl_end.inc
16
17=== added file 'Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490-master.opt'
18--- Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490-master.opt 1970-01-01 00:00:00 +0000
19+++ Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490-master.opt 2013-03-07 19:06:28 +0000
20@@ -0,0 +1,1 @@
21+--max-allowed_packet=4M
22
23=== added file 'Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490-slave.opt'
24--- Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490-slave.opt 1970-01-01 00:00:00 +0000
25+++ Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490-slave.opt 2013-03-07 19:06:28 +0000
26@@ -0,0 +1,2 @@
27+--max_allowed_packet=1M
28+--slave_max_allowed_packet=1G
29
30=== added file 'Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490.test'
31--- Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490.test 1970-01-01 00:00:00 +0000
32+++ Percona-Server/mysql-test/suite/rpl/t/rpl_bug68490.test 2013-03-07 19:06:28 +0000
33@@ -0,0 +1,21 @@
34+--source include/have_binlog_format_row.inc
35+--source include/master-slave.inc
36+
37+--disable_warnings
38+DROP TABLE IF EXISTS t1;
39+sync_slave_with_master;
40+--enable_warnings
41+
42+connection master;
43+CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, payload MEDIUMBLOB NOT NULL);
44+
45+--let $rpl_server_number= 1
46+--source include/rpl_restart_server.inc
47+
48+INSERT INTO t1(payload) VALUES(REPEAT('a',1468872));
49+sync_slave_with_master;
50+
51+connection master;
52+DROP TABLE t1;
53+
54+--source include/rpl_end.inc
55
56=== modified file 'Percona-Server/sql/rpl_slave.cc'
57--- Percona-Server/sql/rpl_slave.cc 2013-03-05 12:46:43 +0000
58+++ Percona-Server/sql/rpl_slave.cc 2013-03-07 19:06:28 +0000
59@@ -4015,16 +4015,6 @@
60 mi->get_user(), mi->host, mi->port,
61 mi->get_io_rpl_log_name(),
62 llstr(mi->get_master_log_pos(), llbuff));
63- /*
64- Assign the max_packet_size with the bigger one of the values of
65- 'max_packet_size' and 'opt_binlog_rows_event_max_size'. So that
66- slave I/O thread can replicate large row event from master.
67- Adding MAX_LOG_EVENT_HEADER_LEN to the max_packet_size on the I/O
68- thread, since a replication event can become this much larger than
69- the corresponding packet (query) sent from client to master.
70- */
71- thd->net.max_packet_size= slave_max_allowed_packet;
72- mysql->net.max_packet_size= thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER;
73 }
74 else
75 {
76@@ -6647,6 +6637,16 @@
77 mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->csname);
78 /* This one is not strictly needed but we have it here for completeness */
79 mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir);
80+ /*
81+ Assign the max_packet_size with the bigger one of the values of
82+ 'max_packet_size' and 'opt_binlog_rows_event_max_size'. So that
83+ slave I/O thread can replicate large row event from master.
84+ Adding MAX_LOG_EVENT_HEADER_LEN to the max_packet_size on the I/O
85+ thread, since a replication event can become this much larger than
86+ the corresponding packet (query) sent from client to master.
87+ */
88+ thd->net.max_packet_size= slave_max_allowed_packet;
89+ mysql->options.max_allowed_packet= thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER;
90
91 if (mi->is_start_plugin_auth_configured())
92 {

Subscribers

People subscribed via source and target branches