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
=== added file 'Percona-Server/mysql-test/r/percona_bug1017192.result'
--- Percona-Server/mysql-test/r/percona_bug1017192.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/r/percona_bug1017192.result 2013-01-04 17:07:25 +0000
@@ -0,0 +1,10 @@
1SET DEBUG_SYNC='reset';
2CREATE TABLE IF NOT EXISTS t1 (`a` INT) ENGINE=InnoDB;
3INSERT INTO t1 VALUES (1),(2),(3),(4);
4SET DEBUG_SYNC='after_copy_data_between_tables SIGNAL run_show_innodb_status
5 WAIT_FOR show_innodb_status_done';
6ALTER TABLE t1 PARTITION BY HASH (`a`) PARTITIONS 4 ;
7SET DEBUG_SYNC='now WAIT_FOR run_show_innodb_status';
8SHOW ENGINE INNODB STATUS;
9SET DEBUG_SYNC='now SIGNAL show_innodb_status_done';
10DROP TABLE t1;
011
=== added file 'Percona-Server/mysql-test/t/percona_bug1017192.test'
--- Percona-Server/mysql-test/t/percona_bug1017192.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/t/percona_bug1017192.test 2013-01-04 17:07:25 +0000
@@ -0,0 +1,40 @@
1########################################################################
2# Bug 1017192: Server crashes in add_identifier on concurrent
3# ALTER TABLE and SHOW ENGINE INNODB STATUS
4# We run concurrent ALTER TABLE PARTITION and execute
5# SHOW ENGINE INNODB STATUS exactly at the moment when
6# temporary tables already created and locked.
7########################################################################
8
9--source include/have_partition.inc
10--source include/have_innodb.inc
11--source include/have_debug_sync.inc
12
13SET DEBUG_SYNC='reset';
14
15CREATE TABLE IF NOT EXISTS t1 (`a` INT) ENGINE=InnoDB;
16INSERT INTO t1 VALUES (1),(2),(3),(4);
17
18--connect (con1,localhost,root,,)
19
20--connection default
21SET DEBUG_SYNC='after_copy_data_between_tables SIGNAL run_show_innodb_status
22 WAIT_FOR show_innodb_status_done';
23--send ALTER TABLE t1 PARTITION BY HASH (`a`) PARTITIONS 4
24--connection con1
25SET DEBUG_SYNC='now WAIT_FOR run_show_innodb_status';
26# We catch the moment when SHOW ENGINE INNODB STATUS should produce lines like:
27# TABLE LOCK table `test`.`#sql-14021_2#P#p1` /* Partition `p1` */ trx id 506 lock mode IX
28# TABLE LOCK table `test`.`#sql-14021_2#P#p2` /* Partition `p2` */ trx id 506 lock mode IX
29# TABLE LOCK table `test`.`#sql-14021_2#P#p3` /* Partition `p3` */ trx id 506 lock mode IX
30# TABLE LOCK table `test`.`#sql-14021_2#P#p0` /* Partition `p0` */ trx id 506 lock mode IX
31# This cause segmentation fault because of incorrect handling of table names
32# which look like `#sql-14021_2#P#p0`
33--disable_result_log
34SHOW ENGINE INNODB STATUS;
35--enable_result_log
36SET DEBUG_SYNC='now SIGNAL show_innodb_status_done';
37--connection default
38--reap
39
40DROP TABLE t1;
041
=== modified file 'Percona-Server/sql/sql_table.cc'
--- Percona-Server/sql/sql_table.cc 2012-10-10 20:32:32 +0000
+++ Percona-Server/sql/sql_table.cc 2013-01-04 17:07:25 +0000
@@ -171,6 +171,13 @@
171 diagnostic, error etc. when it would be useful to know what a particular171 diagnostic, error etc. when it would be useful to know what a particular
172 file [and directory] means. Such as SHOW ENGINE STATUS, error messages etc.172 file [and directory] means. Such as SHOW ENGINE STATUS, error messages etc.
173173
174 Examples:
175
176 t1#P#p1 table t1 partition p1
177 t1#P#p1#SP#sp1 table t1 partition p1 subpartition sp1
178 t1#P#p1#SP#sp1#TMP# table t1 partition p1 subpartition sp1 temporary
179 t1#P#p1#SP#sp1#REN# table t1 partition p1 subpartition sp1 renamed
180
174 @param thd Thread handle181 @param thd Thread handle
175 @param from Path name in my_charset_filename182 @param from Path name in my_charset_filename
176 Null terminated in my_charset_filename, normalized183 Null terminated in my_charset_filename, normalized
@@ -209,7 +216,7 @@
209 int part_name_len= 0;216 int part_name_len= 0;
210 const char *subpart_name= NULL;217 const char *subpart_name= NULL;
211 int subpart_name_len= 0;218 int subpart_name_len= 0;
212 enum enum_file_name_type {NORMAL, TEMP, RENAMED} name_type= NORMAL;219 uint name_variant= NORMAL_PART_NAME;
213 const char *tmp_p;220 const char *tmp_p;
214 DBUG_ENTER("explain_filename");221 DBUG_ENTER("explain_filename");
215 DBUG_PRINT("enter", ("from '%s'", from));222 DBUG_PRINT("enter", ("from '%s'", from));
@@ -252,7 +259,6 @@
252 (tmp_p[2] == 'L' || tmp_p[2] == 'l') &&259 (tmp_p[2] == 'L' || tmp_p[2] == 'l') &&
253 tmp_p[3] == '-')260 tmp_p[3] == '-')
254 {261 {
255 name_type= TEMP;
256 tmp_p+= 4; /* sql- prefix found */262 tmp_p+= 4; /* sql- prefix found */
257 }263 }
258 else264 else
@@ -263,7 +269,7 @@
263 if ((tmp_p[1] == 'M' || tmp_p[1] == 'm') &&269 if ((tmp_p[1] == 'M' || tmp_p[1] == 'm') &&
264 (tmp_p[2] == 'P' || tmp_p[2] == 'p') &&270 (tmp_p[2] == 'P' || tmp_p[2] == 'p') &&
265 tmp_p[3] == '#' && !tmp_p[4])271 tmp_p[3] == '#' && !tmp_p[4])
266 name_type= TEMP;272 name_variant= TEMP_PART_NAME;
267 else273 else
268 res= 3;274 res= 3;
269 tmp_p+= 4;275 tmp_p+= 4;
@@ -273,7 +279,7 @@
273 if ((tmp_p[1] == 'E' || tmp_p[1] == 'e') &&279 if ((tmp_p[1] == 'E' || tmp_p[1] == 'e') &&
274 (tmp_p[2] == 'N' || tmp_p[2] == 'n') &&280 (tmp_p[2] == 'N' || tmp_p[2] == 'n') &&
275 tmp_p[3] == '#' && !tmp_p[4])281 tmp_p[3] == '#' && !tmp_p[4])
276 name_type= RENAMED;282 name_variant= RENAMED_PART_NAME;
277 else283 else
278 res= 4;284 res= 4;
279 tmp_p+= 4;285 tmp_p+= 4;
@@ -298,7 +304,7 @@
298 subpart_name_len= strlen(subpart_name);304 subpart_name_len= strlen(subpart_name);
299 else305 else
300 part_name_len= strlen(part_name);306 part_name_len= strlen(part_name);
301 if (name_type != NORMAL)307 if (name_variant != NORMAL_PART_NAME)
302 {308 {
303 if (subpart_name)309 if (subpart_name)
304 subpart_name_len-= 5;310 subpart_name_len-= 5;
@@ -340,9 +346,9 @@
340 to_p= strnmov(to_p, " ", end_p - to_p);346 to_p= strnmov(to_p, " ", end_p - to_p);
341 else347 else
342 to_p= strnmov(to_p, ", ", end_p - to_p);348 to_p= strnmov(to_p, ", ", end_p - to_p);
343 if (name_type != NORMAL)349 if (name_variant != NORMAL_PART_NAME)
344 {350 {
345 if (name_type == TEMP)351 if (name_variant == TEMP_PART_NAME)
346 to_p= strnmov(to_p, ER_THD_OR_DEFAULT(thd, ER_TEMPORARY_NAME),352 to_p= strnmov(to_p, ER_THD_OR_DEFAULT(thd, ER_TEMPORARY_NAME),
347 end_p - to_p);353 end_p - to_p);
348 else354 else
@@ -7397,6 +7403,8 @@
7397 free_io_cache(from);7403 free_io_cache(from);
7398 delete [] copy; // This is never 07404 delete [] copy; // This is never 0
73997405
7406 DEBUG_SYNC(thd, "after_copy_data_between_tables");
7407
7400 if (to->file->ha_end_bulk_insert() && error <= 0)7408 if (to->file->ha_end_bulk_insert() && error <= 0)
7401 {7409 {
7402 to->file->print_error(my_errno,MYF(0));7410 to->file->print_error(my_errno,MYF(0));

Subscribers

People subscribed via source and target branches