Commit 1a647b70 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-25487 Assertion failed in lock_rec_move

row_ins_clust_index_entry_low(): Do not enable bulk insert if
any record locks exist on the table. Bulk insert is assumed to
be covered only by an exclusive table lock, with no row-level
locking or undo logging.
parent ee20e26d
......@@ -137,3 +137,25 @@ c
SELECT * FROM t2;
c
DROP TABLE t1,t2;
#
# MDEV-25487 Assertion failed in lock_rec_move
#
CREATE TABLE t1 (a INT KEY) ENGINE=InnoDB;
SET @save_limit = @@GLOBAL.innodb_limit_optimistic_insert_debug;
SET GLOBAL innodb_limit_optimistic_insert_debug = 2;
BEGIN;
SELECT * FROM t1 LOCK IN SHARE MODE;
a
INSERT INTO t1 VALUES (0),(1),(2);
INSERT INTO t1 VALUES (0,1);
ERROR 21S01: Column count doesn't match value count at row 1
INSERT INTO t1 VALUES (2);
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
COMMIT;
SET GLOBAL innodb_limit_optimistic_insert_debug = @save_limit;
SELECT * FROM t1;
a
0
1
2
DROP TABLE t1;
--source include/have_innodb.inc
--source include/have_sequence.inc
--source include/maybe_debug.inc
# Enable MDEV-515 table-level undo logging for insert into empty table
SET foreign_key_checks=0, unique_checks=0;
......@@ -139,3 +140,30 @@ COMMIT;
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t1,t2;
--echo #
--echo # MDEV-25487 Assertion failed in lock_rec_move
--echo #
CREATE TABLE t1 (a INT KEY) ENGINE=InnoDB;
--error 0,1193
SET @save_limit = @@GLOBAL.innodb_limit_optimistic_insert_debug;
--error 0,1193
SET GLOBAL innodb_limit_optimistic_insert_debug = 2;
BEGIN;
SELECT * FROM t1 LOCK IN SHARE MODE;
INSERT INTO t1 VALUES (0),(1),(2);
--error ER_WRONG_VALUE_COUNT_ON_ROW
INSERT INTO t1 VALUES (0,1);
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES (2);
COMMIT;
--error 0,ER_UNKNOWN_SYSTEM_VARIABLE
SET GLOBAL innodb_limit_optimistic_insert_debug = @save_limit;
SELECT * FROM t1;
DROP TABLE t1;
......@@ -2669,6 +2669,7 @@ row_ins_clust_index_entry_low(
&& !trx->ddl && !trx->internal
&& block->page.id().page_no() == index->page
&& !index->table->skip_alter_undo
&& !index->table->n_rec_locks
&& !trx->is_wsrep() /* FIXME: MDEV-24623 */
&& !thd_is_slave(trx->mysql_thd) /* FIXME: MDEV-24622 */) {
DEBUG_SYNC_C("empty_root_page_insert");
......@@ -2681,6 +2682,10 @@ row_ins_clust_index_entry_low(
goto commit_exit;
}
if (index->table->n_rec_locks) {
goto skip_bulk_insert;
}
#ifdef BTR_CUR_HASH_ADAPT
if (btr_search_enabled) {
btr_search_x_lock_all();
......@@ -2697,9 +2702,7 @@ row_ins_clust_index_entry_low(
trx->bulk_insert = true;
}
#ifndef DBUG_OFF
skip_bulk_insert:
#endif
if (UNIV_UNLIKELY(entry->info_bits != 0)) {
ut_ad(entry->is_metadata());
ut_ad(flags == BTR_NO_LOCKING_FLAG);
......
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