diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index 798e3b9a6bf..f1c3795791a 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -765,3 +765,37 @@ f1 f2 f3 f4 f5 f6 INSERT INTO t3 SELECT * FROM t2 WHERE f3 = 'm' AND f2 ='c'; DROP TABLE t1,t2,t3; set global default_storage_engine=default; +# +# Bug#13737949: CRASH IN HA_PARTITION::INDEX_INIT +# Bug#18694052: SERVER CRASH IN HA_PARTITION::INIT_RECORD_PRIORITY_QUEUE +# +CREATE TABLE t1 +(a INT, +b INT, +PRIMARY KEY (a)) +ENGINE = InnoDB +PARTITION BY HASH (a) PARTITIONS 3; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +# con1 +ALTER TABLE t1 ADD INDEX idx1 (b); +# con default +SELECT b FROM t1 WHERE b = 0; +ERROR HY000: Table definition has changed, please retry transaction +SELECT b FROM t1 WHERE b = 0; +ERROR HY000: Table definition has changed, please retry transaction +DROP TABLE t1; +# Same test without partitioning +CREATE TABLE t1 +(a INT, +b INT, +PRIMARY KEY (a)) +ENGINE = InnoDB; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +# con1 +ALTER TABLE t1 ADD INDEX idx1 (b); +# con default +SELECT b FROM t1 WHERE b = 0; +ERROR HY000: Table definition has changed, please retry transaction +SELECT b FROM t1 WHERE b = 0; +ERROR HY000: Table definition has changed, please retry transaction +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_debug.result b/mysql-test/suite/parts/r/partition_debug.result index 3f0f2def790..109072be49c 100644 --- a/mysql-test/suite/parts/r/partition_debug.result +++ b/mysql-test/suite/parts/r/partition_debug.result @@ -1,5 +1,21 @@ DROP TABLE IF EXISTS t1; # +# Bug#13737949: CRASH IN HA_PARTITION::INDEX_INIT +# Bug#18694052: SERVER CRASH IN HA_PARTITION::INIT_RECORD_PRIORITY_QUEUE +# +CREATE TABLE t1 (a INT, b VARCHAR(64), KEY(b,a)) +PARTITION BY HASH (a) PARTITIONS 3; +INSERT INTO t1 VALUES (1, "1"), (2, "2"), (3, "3"), (4, "Four"), (5, "Five"), +(6, "Six"), (7, "Seven"), (8, "Eight"), (9, "Nine"); +SET SESSION debug_dbug="+d,ha_partition_fail_index_init"; +SELECT * FROM t1 WHERE b = "Seven"; +ERROR HY000: Table has no partition for value 0 +SET SESSION debug_dbug="-d,ha_partition_fail_index_init"; +SELECT * FROM t1 WHERE b = "Seven"; +a b +7 Seven +DROP TABLE t1; +# # WL#4445: EXCHANGE PARTITION WITH TABLE # Verify ddl_log in case of crashing. call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); diff --git a/mysql-test/suite/parts/t/partition_debug.test b/mysql-test/suite/parts/t/partition_debug.test index aa943e5fbe1..11b66e4afd8 100644 --- a/mysql-test/suite/parts/t/partition_debug.test +++ b/mysql-test/suite/parts/t/partition_debug.test @@ -12,6 +12,24 @@ DROP TABLE IF EXISTS t1; --enable_warnings +# Partitioning test that require debug features + +--echo # +--echo # Bug#13737949: CRASH IN HA_PARTITION::INDEX_INIT +--echo # Bug#18694052: SERVER CRASH IN HA_PARTITION::INIT_RECORD_PRIORITY_QUEUE +--echo # +CREATE TABLE t1 (a INT, b VARCHAR(64), KEY(b,a)) + PARTITION BY HASH (a) PARTITIONS 3; + INSERT INTO t1 VALUES (1, "1"), (2, "2"), (3, "3"), (4, "Four"), (5, "Five"), + (6, "Six"), (7, "Seven"), (8, "Eight"), (9, "Nine"); +SET SESSION debug_dbug="+d,ha_partition_fail_index_init"; +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +SELECT * FROM t1 WHERE b = "Seven"; +SET SESSION debug_dbug="-d,ha_partition_fail_index_init"; +SELECT * FROM t1 WHERE b = "Seven"; +DROP TABLE t1; + + --let $DATADIR= `SELECT @@datadir;` --echo # diff --git a/mysql-test/t/AAA.test b/mysql-test/t/AAA.test new file mode 100644 index 00000000000..e9547e84108 --- /dev/null +++ b/mysql-test/t/AAA.test @@ -0,0 +1,66 @@ +#delimiter |; +#create procedure p0(x int) +#while x do +# set x = x-1; +#end while| +#delimiter ;| +#call p0(100000000); +#drop procedure p0; +# +#disable_query_log; +#disable_result_log; +#let $1= 100000000; +#while ($1) +#{ +# SELECT 1; +# dec $1; +#} +#enable_query_log; +#enable_result_log; +#SELECT 'done'; + +--source include/have_innodb.inc +--source include/have_partition.inc + +--enable_connect_log + +SET GLOBAL innodb_lock_wait_timeout = 3; + +CREATE TABLE t1 (pk int auto_increment primary key) ENGINE=InnoDB + PARTITION BY key (pk) partitions 2; + +CREATE TABLE t2 (pk int auto_increment primary key) ENGINE=InnoDB; + +CREATE TABLE t3 (f int) ENGINE=InnoDB; +INSERT INTO t3 VALUES (1),(2); + +--connect (con1,localhost,root,,test) +--connect (con2,localhost,root,,test) +--send ALTER TABLE t1 FORCE; + +--connect (con3,localhost,root,,test) +START TRANSACTION; +INSERT INTO t2 VALUES (1),(2); + +--connection con1 +send UPDATE t3 SET f = 5; + +--connection con3 +SELECT f FROM t3; + +--connection con1 +reap; +--error ER_LOCK_WAIT_TIMEOUT +DELETE FROM t2; + +--connection con3 +--error 0,ER_TABLE_DEF_CHANGED +REPLACE INTO t2 (pk) SELECT NULL FROM t1; + +SELECT * FROM t1; + +disconnect con1; +disconnect con2; +disconnect con3; +connection default; +DROP TABLES t1, t2, t3; diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index 2d90764da0d..6845cca10fb 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -856,3 +856,45 @@ INSERT INTO t3 SELECT * FROM t2 WHERE f3 = 'm' AND f2 ='c'; DROP TABLE t1,t2,t3; set global default_storage_engine=default; + +--echo # +--echo # Bug#13737949: CRASH IN HA_PARTITION::INDEX_INIT +--echo # Bug#18694052: SERVER CRASH IN HA_PARTITION::INIT_RECORD_PRIORITY_QUEUE +--echo # +CREATE TABLE t1 +(a INT, + b INT, + PRIMARY KEY (a)) + ENGINE = InnoDB + PARTITION BY HASH (a) PARTITIONS 3; + START TRANSACTION WITH CONSISTENT SNAPSHOT; + --connect (con1, localhost, root,,) + --echo # con1 + ALTER TABLE t1 ADD INDEX idx1 (b); + --connection default + --echo # con default + --error ER_TABLE_DEF_CHANGED + SELECT b FROM t1 WHERE b = 0; + --error ER_TABLE_DEF_CHANGED + SELECT b FROM t1 WHERE b = 0; + --disconnect con1 + DROP TABLE t1; + +--echo # Same test without partitioning +CREATE TABLE t1 +(a INT, + b INT, + PRIMARY KEY (a)) + ENGINE = InnoDB; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +--echo # con1 +--connect (con1, localhost, root,,) +ALTER TABLE t1 ADD INDEX idx1 (b); +--connection default +--echo # con default +--error ER_TABLE_DEF_CHANGED +SELECT b FROM t1 WHERE b = 0; +--error ER_TABLE_DEF_CHANGED +SELECT b FROM t1 WHERE b = 0; +--disconnect con1 +DROP TABLE t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index d8fc647d2a2..e59954e13c2 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -5271,6 +5271,7 @@ err: { (void) m_file[j]->ha_index_end(); } + destroy_record_priority_queue(); } DBUG_RETURN(error); }