Skip to content

Commit

Permalink
MDEV-28037 Assertion `trx->bulk_insert' failed in innodb_prepare_comm…
Browse files Browse the repository at this point in the history
…it_versioned

- Trigger statement initiate update statement after bulk insert
operation and leads to disable of bulk operation. During commit,
InnoDB expects transaction to be in bulk insert mode before
applying the bulk insert operation. InnoDB transaction should
apply all bulk insert operation before disabling bulk insert
operation.
  • Loading branch information
Thirunarayanan committed Apr 12, 2022
1 parent e858fc8 commit 011b332
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mysql-test/suite/innodb/r/insert_into_empty.result
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,16 @@ INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(0),(0);
ERROR HY000: Got error 1 "Operation not permitted" during COMMIT
DELETE FROM t1;
DROP TABLE t1;
#
# MDEV-28037 Assertion `trx->bulk_insert' failed in innodb_prepare_commit_versioned
#
CREATE TABLE t1 (c INT) ENGINE=InnoDB;
CREATE TABLE t2 (c INT) ENGINE=InnoDB;
CREATE TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW UPDATE t2 SET c=1;
INSERT INTO t1 VALUES (0);
SELECT * FROM t1;
c
0
SELECT * FROM t2;
c
DROP TABLE t2, t1;
11 changes: 11 additions & 0 deletions mysql-test/suite/innodb/t/insert_into_empty.test
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,14 @@ CREATE TABLE t1 (c0 YEAR UNIQUE) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(0),(0);
DELETE FROM t1;
DROP TABLE t1;

--echo #
--echo # MDEV-28037 Assertion `trx->bulk_insert' failed in innodb_prepare_commit_versioned
--echo #
CREATE TABLE t1 (c INT) ENGINE=InnoDB;
CREATE TABLE t2 (c INT) ENGINE=InnoDB;
CREATE TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW UPDATE t2 SET c=1;
INSERT INTO t1 VALUES (0);
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t2, t1;
6 changes: 6 additions & 0 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15836,6 +15836,12 @@ ha_innobase::start_stmt(
if (!trx->bulk_insert) {
break;
}

/* Trigger could've initiated another stmt.
So apply all bulk operation and mark as
end bulk insert for all tables */
trx->bulk_insert_apply();
trx->end_bulk_insert();
trx->bulk_insert = false;
trx->last_sql_stat_start.least_undo_no = trx->undo_no;
}
Expand Down

0 comments on commit 011b332

Please sign in to comment.