Merge lp:~sergei.glushchenko/percona-server/ps55-bug1017192 into lp:percona-server/5.5

Proposed by Sergei Glushchenko
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 408
Proposed branch: lp:~sergei.glushchenko/percona-server/ps55-bug1017192
Merge into: lp:percona-server/5.5
Diff against target: 142 lines (+65/-7)
3 files modified
Percona-Server/mysql-test/r/percona_bug1017192.result (+10/-0)
Percona-Server/mysql-test/t/percona_bug1017192.test (+40/-0)
Percona-Server/sql/sql_table.cc (+15/-7)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-server/ps55-bug1017192
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Review via email: mp+141955@code.launchpad.net

Description of the change

Fix for bug 1036506 (Server crashes in add_identifier on
concurrent ALTER TABLE and SHOW ENGINE INNODB STATUS).
This is a port of fix for MDEV-364 by Sergei Golubchik.
Fix explain_tablename() to distinguish between temporary
tables (#sql- prefix) and temporary partitions
(#TMP# suffix). Change explain_tablename() to use the
same name variant constants as sql_partition.cc does.
Add testcase which catches the moment
SHOW ENGINE INNODB STATUS outputs the list of locked
temporary partitions.

http://jenkins.percona.com/view/PS%205.5/job/percona-server-5.5-param/612/

To post a comment you must log in.
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/r/percona_bug1017192.result'
2--- Percona-Server/mysql-test/r/percona_bug1017192.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/r/percona_bug1017192.result 2013-01-04 17:07:25 +0000
4@@ -0,0 +1,10 @@
5+SET DEBUG_SYNC='reset';
6+CREATE TABLE IF NOT EXISTS t1 (`a` INT) ENGINE=InnoDB;
7+INSERT INTO t1 VALUES (1),(2),(3),(4);
8+SET DEBUG_SYNC='after_copy_data_between_tables SIGNAL run_show_innodb_status
9+ WAIT_FOR show_innodb_status_done';
10+ALTER TABLE t1 PARTITION BY HASH (`a`) PARTITIONS 4 ;
11+SET DEBUG_SYNC='now WAIT_FOR run_show_innodb_status';
12+SHOW ENGINE INNODB STATUS;
13+SET DEBUG_SYNC='now SIGNAL show_innodb_status_done';
14+DROP TABLE t1;
15
16=== added file 'Percona-Server/mysql-test/t/percona_bug1017192.test'
17--- Percona-Server/mysql-test/t/percona_bug1017192.test 1970-01-01 00:00:00 +0000
18+++ Percona-Server/mysql-test/t/percona_bug1017192.test 2013-01-04 17:07:25 +0000
19@@ -0,0 +1,40 @@
20+########################################################################
21+# Bug 1017192: Server crashes in add_identifier on concurrent
22+# ALTER TABLE and SHOW ENGINE INNODB STATUS
23+# We run concurrent ALTER TABLE PARTITION and execute
24+# SHOW ENGINE INNODB STATUS exactly at the moment when
25+# temporary tables already created and locked.
26+########################################################################
27+
28+--source include/have_partition.inc
29+--source include/have_innodb.inc
30+--source include/have_debug_sync.inc
31+
32+SET DEBUG_SYNC='reset';
33+
34+CREATE TABLE IF NOT EXISTS t1 (`a` INT) ENGINE=InnoDB;
35+INSERT INTO t1 VALUES (1),(2),(3),(4);
36+
37+--connect (con1,localhost,root,,)
38+
39+--connection default
40+SET DEBUG_SYNC='after_copy_data_between_tables SIGNAL run_show_innodb_status
41+ WAIT_FOR show_innodb_status_done';
42+--send ALTER TABLE t1 PARTITION BY HASH (`a`) PARTITIONS 4
43+--connection con1
44+SET DEBUG_SYNC='now WAIT_FOR run_show_innodb_status';
45+# We catch the moment when SHOW ENGINE INNODB STATUS should produce lines like:
46+# TABLE LOCK table `test`.`#sql-14021_2#P#p1` /* Partition `p1` */ trx id 506 lock mode IX
47+# TABLE LOCK table `test`.`#sql-14021_2#P#p2` /* Partition `p2` */ trx id 506 lock mode IX
48+# TABLE LOCK table `test`.`#sql-14021_2#P#p3` /* Partition `p3` */ trx id 506 lock mode IX
49+# TABLE LOCK table `test`.`#sql-14021_2#P#p0` /* Partition `p0` */ trx id 506 lock mode IX
50+# This cause segmentation fault because of incorrect handling of table names
51+# which look like `#sql-14021_2#P#p0`
52+--disable_result_log
53+SHOW ENGINE INNODB STATUS;
54+--enable_result_log
55+SET DEBUG_SYNC='now SIGNAL show_innodb_status_done';
56+--connection default
57+--reap
58+
59+DROP TABLE t1;
60
61=== modified file 'Percona-Server/sql/sql_table.cc'
62--- Percona-Server/sql/sql_table.cc 2012-10-10 20:32:32 +0000
63+++ Percona-Server/sql/sql_table.cc 2013-01-04 17:07:25 +0000
64@@ -171,6 +171,13 @@
65 diagnostic, error etc. when it would be useful to know what a particular
66 file [and directory] means. Such as SHOW ENGINE STATUS, error messages etc.
67
68+ Examples:
69+
70+ t1#P#p1 table t1 partition p1
71+ t1#P#p1#SP#sp1 table t1 partition p1 subpartition sp1
72+ t1#P#p1#SP#sp1#TMP# table t1 partition p1 subpartition sp1 temporary
73+ t1#P#p1#SP#sp1#REN# table t1 partition p1 subpartition sp1 renamed
74+
75 @param thd Thread handle
76 @param from Path name in my_charset_filename
77 Null terminated in my_charset_filename, normalized
78@@ -209,7 +216,7 @@
79 int part_name_len= 0;
80 const char *subpart_name= NULL;
81 int subpart_name_len= 0;
82- enum enum_file_name_type {NORMAL, TEMP, RENAMED} name_type= NORMAL;
83+ uint name_variant= NORMAL_PART_NAME;
84 const char *tmp_p;
85 DBUG_ENTER("explain_filename");
86 DBUG_PRINT("enter", ("from '%s'", from));
87@@ -252,7 +259,6 @@
88 (tmp_p[2] == 'L' || tmp_p[2] == 'l') &&
89 tmp_p[3] == '-')
90 {
91- name_type= TEMP;
92 tmp_p+= 4; /* sql- prefix found */
93 }
94 else
95@@ -263,7 +269,7 @@
96 if ((tmp_p[1] == 'M' || tmp_p[1] == 'm') &&
97 (tmp_p[2] == 'P' || tmp_p[2] == 'p') &&
98 tmp_p[3] == '#' && !tmp_p[4])
99- name_type= TEMP;
100+ name_variant= TEMP_PART_NAME;
101 else
102 res= 3;
103 tmp_p+= 4;
104@@ -273,7 +279,7 @@
105 if ((tmp_p[1] == 'E' || tmp_p[1] == 'e') &&
106 (tmp_p[2] == 'N' || tmp_p[2] == 'n') &&
107 tmp_p[3] == '#' && !tmp_p[4])
108- name_type= RENAMED;
109+ name_variant= RENAMED_PART_NAME;
110 else
111 res= 4;
112 tmp_p+= 4;
113@@ -298,7 +304,7 @@
114 subpart_name_len= strlen(subpart_name);
115 else
116 part_name_len= strlen(part_name);
117- if (name_type != NORMAL)
118+ if (name_variant != NORMAL_PART_NAME)
119 {
120 if (subpart_name)
121 subpart_name_len-= 5;
122@@ -340,9 +346,9 @@
123 to_p= strnmov(to_p, " ", end_p - to_p);
124 else
125 to_p= strnmov(to_p, ", ", end_p - to_p);
126- if (name_type != NORMAL)
127+ if (name_variant != NORMAL_PART_NAME)
128 {
129- if (name_type == TEMP)
130+ if (name_variant == TEMP_PART_NAME)
131 to_p= strnmov(to_p, ER_THD_OR_DEFAULT(thd, ER_TEMPORARY_NAME),
132 end_p - to_p);
133 else
134@@ -7397,6 +7403,8 @@
135 free_io_cache(from);
136 delete [] copy; // This is never 0
137
138+ DEBUG_SYNC(thd, "after_copy_data_between_tables");
139+
140 if (to->file->ha_end_bulk_insert() && error <= 0)
141 {
142 to->file->print_error(my_errno,MYF(0));

Subscribers

People subscribed via source and target branches