[MDEV-26251] CREATE INDEX on virtual column ignores errors due to concurrent DML Created: 2021-07-27  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.2.2, 10.3.0, 10.4.0, 10.5.0, 10.6.0
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Nikita Malyavin
Resolution: Unresolved Votes: 0
Labels: corruption, race

Issue Links:
Relates
relates to MDEV-20154 Assertion `len <= col->len || ((col->... Closed
relates to MDEV-26229 Innodb crash after insert while concu... Stalled

 Description   

A peculiar design constraint of MariaDB virtual columns is that evaluation errors for non-indexed virtual columns are allowed (only reported when attempting to read from the virtual column).

If an index on a virtual column exists, then an INSERT that causes (say) a division by 0 would be rejected, like the test case below shows. But, we are not consistently enforcing this rule during online CREATE INDEX: we wrongly allow erroneous data to be inserted into the secondary indexes as NULL values.

--source include/have_innodb.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
 
CREATE TABLE t(a INT, b INT AS (a/a) VIRTUAL) ENGINE=InnoDB;
 
INSERT INTO t SET a=0;
SELECT * FROM t;
DELETE FROM t;
 
ALTER TABLE t ADD INDEX(b);
--error ER_DIVISION_BY_ZERO
INSERT INTO t SET a=0;
 
ALTER TABLE t DROP INDEX b;
 
connect (con1,localhost,root,,);
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL scanned WAIT_FOR apply';
send ALTER TABLE t ADD INDEX(b);
 
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR scanned';
INSERT INTO t SET a=0;
SET DEBUG_SYNC = 'now SIGNAL apply';
 
connection con1;
--echo # ERROR 1: The ALTER TABLE fails to fail!
#--error ER_DIVISION_BY_ZERO
reap;
connection default;
 
SELECT * FROM t;
CHECK TABLE t;
 
DELETE FROM t;
ALTER TABLE t DROP INDEX b;
connection con1;
SET DEBUG_SYNC = 'row_log_apply_after SIGNAL applied WAIT_FOR commit';
send ALTER TABLE t ADD INDEX(b);
 
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR applied';
INSERT INTO t SET a=0;
SET DEBUG_SYNC = 'now SIGNAL commit';
 
connection con1;
--echo # ERROR 2: The ALTER TABLE fails to fail!
#--error ER_DIVISION_BY_ZERO
reap;
connection default;
 
CHECK TABLE t;
SELECT * FROM t;
SHOW CREATE TABLE t;
 
SET DEBUG_SYNC = RESET;
DROP TABLE t;

I think that the logic needs to be fixed so that both ERROR cases highlighted by the test will be reported correctly.


Generated at Thu Feb 08 09:43:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.