[MDEV-31985] IGNORE in INSERT and LOAD are being ignored in InnoDB bulk insert Created: 2023-08-22  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Data Manipulation - Insert
Affects Version/s: 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0, 11.1, 11.2, 11.3
Fix Version/s: 10.6, 10.11, 11.0, 11.1, 11.2, 11.3

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: regression

Issue Links:
Relates
relates to MDEV-24818 Concurrent use of InnoDB table is imp... Closed
relates to MDEV-25036 use bulk insert optimization for mult... Open
relates to MDEV-31835 LOAD DATA into InnoDB w/partitions: h... Closed
relates to MDEV-32439 INSERT IGNORE on constraints result i... Closed

 Description   

In MDEV-31835 we found out an unintended side effect of MDEV-24818, which affects the following test:

--source include/have_innodb.inc
SET foreign_key_checks=0, unique_checks=0;
CREATE TABLE t (a INT UNIQUE) ENGINE=InnoDB;
BEGIN;
INSERT INTO t VALUES(1),(2);
INSERT IGNORE INTO t VALUES(2);
COMMIT;
SELECT * FROM t;
DROP TABLE t;

Before MDEV-24818 was implemented in the MariaDB Server 10.6 branch that was eventually released as 10.6.0, only the first INSERT statement was executed in "bulk insert into empty table" mode. After that change, also the INSERT IGNORE statement will be executed in the same mode, covered by the table-level undo log record "on rollback, make the table empty" that was written by the first INSERT statement. That is, the attempt to insert duplicate key a=2 will result in an empty table, instead of a table that contains the two rows (1),(2).

serg wrote in MDEV-31835 that the INSERT and LOAD statements containing an IGNORE clause must be rejected with an error in this case. As far as I understand, this would have to be implemented in the functions mysql_insert() and mysql_load().

If we want to limit this to the case of InnoDB bulk insert and not the generic case of unique_checks=0, some storage engine API change may be necessary, to query the value of InnoDB trx_t::bulk_insert.


Generated at Thu Feb 08 10:27:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.