Commit e1ed331c authored by Aditya A's avatar Aditya A Committed by Sergey Vojtovich

MDEV-8805 - Assertion `!m_ordered_rec_buffer' failed in

            ha_partition::init_record_priority_queue()

Cherry-pick rev.6b0ee0c795499cee7f9deb649fb010801e0be4c2 from mysql-5.6.

Bug #18305270  BACKPORT BUG#18694052 FIX
               FOR ASSERTION `!M_ORDERED_REC_BUFFER'
               FAILED TO 5.6

PROBLEM
-------
Missed to remove record priority queue if
init_index failed for a partition which
was causing the crash.

FIX
---
Remove priority queue if init_index fails
for partition.
parent 4834d822
...@@ -765,3 +765,37 @@ f1 f2 f3 f4 f5 f6 ...@@ -765,3 +765,37 @@ f1 f2 f3 f4 f5 f6
INSERT INTO t3 SELECT * FROM t2 WHERE f3 = 'm' AND f2 ='c'; INSERT INTO t3 SELECT * FROM t2 WHERE f3 = 'm' AND f2 ='c';
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
set global default_storage_engine=default; 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;
DROP TABLE IF EXISTS t1; 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 # WL#4445: EXCHANGE PARTITION WITH TABLE
# Verify ddl_log in case of crashing. # Verify ddl_log in case of crashing.
call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); call mtr.add_suppression("Attempting backtrace. You can use the following information to find out");
......
...@@ -12,6 +12,24 @@ ...@@ -12,6 +12,24 @@
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
--enable_warnings --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;` --let $DATADIR= `SELECT @@datadir;`
--echo # --echo #
......
#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;
...@@ -856,3 +856,45 @@ INSERT INTO t3 SELECT * FROM t2 WHERE f3 = 'm' AND f2 ='c'; ...@@ -856,3 +856,45 @@ INSERT INTO t3 SELECT * FROM t2 WHERE f3 = 'm' AND f2 ='c';
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
set global default_storage_engine=default; 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;
...@@ -5271,6 +5271,7 @@ err: ...@@ -5271,6 +5271,7 @@ err:
{ {
(void) m_file[j]->ha_index_end(); (void) m_file[j]->ha_index_end();
} }
destroy_record_priority_queue();
} }
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment