[Commits] 4352397eb83: MDEV-18820 Assertion `lock_table_has(trx, index->table, LOCK_IX)' failed in lock_rec_insert_check_and_lock upon INSERT into table with blob key
revision-id: 4352397eb8383ecc23e15dd4f92d248e0d36cc85 (mariadb-10.4.3-105-g4352397eb83) parent(s): 5469d88e7b4e723e545cd7d511801a16a3642dc4 author: Sachin committer: Sachin timestamp: 2019-03-28 14:16:13 +0530 message: MDEV-18820 Assertion `lock_table_has(trx, index->table, LOCK_IX)' failed in lock_rec_insert_check_and_lock upon INSERT into table with blob key Don't Ignore Any error during index lookup, And throw duplicate key error only if error is HA_ERR_FOUND_DUPP_KEY --- mysql-test/main/long_unique_bugs.result | 26 ++++++++++++++++++++ mysql-test/main/long_unique_bugs.test | 43 +++++++++++++++++++++++++++++++++ sql/handler.cc | 6 ++--- 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 48e74bdd564..9b0df9e32fe 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -285,3 +285,29 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ALTER TABLE t1 FORCE; DROP TABLE t1; +set innodb_lock_wait_timeout= 10; +CREATE TABLE t1 ( +id int primary key, +f INT unique +) ENGINE=InnoDB; +CREATE TABLE t2 ( +id int primary key, +a blob unique +) ENGINE=InnoDB; +START TRANSACTION; +connect con1,localhost,root,,test; +connection con1; +set innodb_lock_wait_timeout= 10; +START TRANSACTION; +INSERT INTO t1 VALUES (1,1)/*1*/; +connection default; +INSERT INTO t2 VALUES (2, 1)/*2*/ ; +connection con1; +INSERT INTO t2 VALUES (3, 1)/*3*/; +connection default; +INSERT IGNORE INTO t1 VALUES (4, 1)/*4*/; +connection con1; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +disconnect con1; +connection default; +DROP TABLE t1, t2; diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 11b1c4f09b6..8e4b950b250 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -294,3 +294,46 @@ ALTER TABLE t1 ADD UNIQUE (b); show create table t1; ALTER TABLE t1 FORCE; DROP TABLE t1; + +# +# MDEV-18820 Assertion `lock_table_has(trx, index->table, LOCK_IX)' failed in lock_rec_insert_check_and_lock upon INSERT into table with blob key' +# + +--source include/have_innodb.inc +set innodb_lock_wait_timeout= 10; + +CREATE TABLE t1 ( + id int primary key, + f INT unique +) ENGINE=InnoDB; + +CREATE TABLE t2 ( + id int primary key, + a blob unique +) ENGINE=InnoDB; + +START TRANSACTION; + +--connect (con1,localhost,root,,test) + +--connection con1 +set innodb_lock_wait_timeout= 10; +START TRANSACTION; +INSERT INTO t1 VALUES (1,1)/*1*/; + +--connection default +INSERT INTO t2 VALUES (2, 1)/*2*/ ; + +--connection con1 +--send + INSERT INTO t2 VALUES (3, 1)/*3*/; + +--connection default +INSERT IGNORE INTO t1 VALUES (4, 1)/*4*/; + +--connection con1 +--error ER_LOCK_DEADLOCK +--reap +--disconnect con1 +--connection default +DROP TABLE t1, t2; diff --git a/sql/handler.cc b/sql/handler.cc index da7850c5c4e..22af3f8bc81 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6590,10 +6590,10 @@ static int check_duplicate_long_entry_key(TABLE *table, handler *h, error= HA_ERR_FOUND_DUPP_KEY; goto exit; } - if (result == HA_ERR_LOCK_WAIT_TIMEOUT) - error= HA_ERR_LOCK_WAIT_TIMEOUT; + if (result != HA_ERR_KEY_NOT_FOUND) + error= result; exit: - if (error) + if (error == HA_ERR_FOUND_DUPP_KEY) { table->file->errkey= key_no; if (h->ha_table_flags() & HA_DUPLICATE_POS)
participants (1)
-
sachin.setiya@mariadb.com