Merge lp:~laurynas-biveinis/percona-server/bug1167486-5.1 into lp:percona-server/5.1

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Sergei Glushchenko
Approved revision: 610
Merged at revision: 617
Proposed branch: lp:~laurynas-biveinis/percona-server/bug1167486-5.1
Merge into: lp:percona-server/5.1
Diff against target: 87 lines (+34/-6)
6 files modified
Percona-Server/mysql-test/r/percona_bug1008278.result (+8/-0)
Percona-Server/mysql-test/t/percona_bug1008278-slave.opt (+1/-0)
Percona-Server/mysql-test/t/percona_bug1008278.test (+23/-0)
Percona-Server/sql/sql_class.cc (+2/-1)
Percona-Server/sql/sql_class.h (+0/-2)
Percona-Server/sql/sql_parse.cc (+0/-3)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug1167486-5.1
Reviewer Review Type Date Requested Status
Sergei Glushchenko (community) g2 Approve
Review via email: mp+222387@code.launchpad.net

Description of the change

Fix bug 1167486 (Valgrind error at THD::update_stats).

The error happens because THD::old_command is uninitialized in some
execution paths (slave SQL thread, bootstrap). The original purpose of
old_command (saving THD::command before overwriting it with COM_SLEEP)
is gone, as all THD::update_stats calls are before the overwrite. Thus
fix by removing this variable, checking THD::command instead and
asserting it's not COM_SLEEP.

Backport percona_bug1008278 testcase from 5.5.

To post a comment you must log in.
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Approve

review: Approve (g2)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Percona-Server/mysql-test/r/percona_bug1008278.result'
2--- Percona-Server/mysql-test/r/percona_bug1008278.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/r/percona_bug1008278.result 2014-06-06 17:59:49 +0000
4@@ -0,0 +1,8 @@
5+include/master-slave.inc
6+[connection master]
7+DROP TABLE IF EXISTS t;
8+CREATE TABLE t(id INT,data CHAR(30));
9+INSERT INTO t VALUES
10+(1,"aaaaabbbbbcccccdddddeeeeefffff");
11+DROP TABLE t;
12+include/rpl_end.inc
13
14=== added file 'Percona-Server/mysql-test/t/percona_bug1008278-slave.opt'
15--- Percona-Server/mysql-test/t/percona_bug1008278-slave.opt 1970-01-01 00:00:00 +0000
16+++ Percona-Server/mysql-test/t/percona_bug1008278-slave.opt 2014-06-06 17:59:49 +0000
17@@ -0,0 +1,1 @@
18+--userstat=1
19
20=== added file 'Percona-Server/mysql-test/t/percona_bug1008278.test'
21--- Percona-Server/mysql-test/t/percona_bug1008278.test 1970-01-01 00:00:00 +0000
22+++ Percona-Server/mysql-test/t/percona_bug1008278.test 2014-06-06 17:59:49 +0000
23@@ -0,0 +1,23 @@
24+# Bug 1008278: The server crashes when replication is started
25+# with "--userstat=1" parameter.
26+# Just start replcation with "--userstat=1" parameter and execute any
27+# query on master to be ensure slave doesn't crash.
28+
29+--source include/have_binlog_format_statement.inc
30+--source include/master-slave.inc
31+
32+connection master;
33+-- disable_warnings
34+DROP TABLE IF EXISTS t;
35+-- enable_warnings
36+
37+CREATE TABLE t(id INT,data CHAR(30));
38+INSERT INTO t VALUES
39+(1,"aaaaabbbbbcccccdddddeeeeefffff");
40+sync_slave_with_master;
41+
42+connection master;
43+DROP TABLE t;
44+sync_slave_with_master;
45+
46+--source include/rpl_end.inc
47
48=== modified file 'Percona-Server/sql/sql_class.cc'
49--- Percona-Server/sql/sql_class.cc 2013-10-22 13:31:04 +0000
50+++ Percona-Server/sql/sql_class.cc 2014-06-06 17:59:49 +0000
51@@ -993,7 +993,8 @@
52
53 if (ran_command) {
54 // The replication thread has the COM_CONNECT command.
55- if ((old_command == COM_QUERY || command == COM_CONNECT) &&
56+ DBUG_ASSERT(command != COM_SLEEP);
57+ if ((command == COM_QUERY || command == COM_CONNECT) &&
58 (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
59 // A SQL query.
60 if (lex->sql_command == SQLCOM_SELECT) {
61
62=== modified file 'Percona-Server/sql/sql_class.h'
63--- Percona-Server/sql/sql_class.h 2013-12-05 07:33:20 +0000
64+++ Percona-Server/sql/sql_class.h 2014-06-06 17:59:49 +0000
65@@ -1485,8 +1485,6 @@
66 first byte of the packet in do_command()
67 */
68 enum enum_server_command command;
69- // Used to save the command, before it is set to COM_SLEEP.
70- enum enum_server_command old_command;
71 uint32 server_id;
72 uint32 file_id; // for LOAD DATA INFILE
73 /* remote (peer) port */
74
75=== modified file 'Percona-Server/sql/sql_parse.cc'
76--- Percona-Server/sql/sql_parse.cc 2013-10-22 13:31:04 +0000
77+++ Percona-Server/sql/sql_parse.cc 2014-06-06 17:59:49 +0000
78@@ -1013,9 +1013,6 @@
79 DBUG_PRINT("info",("packet: '%*.s'; command: %d", packet_length, packet, command));
80
81 thd->command=command;
82- // To increment the corrent command counter for user stats, 'command' must
83- // be saved because it is set to COM_SLEEP at the end of this function.
84- thd->old_command = command;
85 /*
86 Commands which always take a long time are logged into
87 the slow log only if opt_log_slow_admin_statements is set.

Subscribers

People subscribed via source and target branches