[MDEV-15219] FOREIGN KEY CASCADE or SET NULL operations will not resume after lock wait Created: 2018-02-06  Updated: 2018-10-24  Resolved: 2018-02-07

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.2.8, 10.3.1
Fix Version/s: 10.2.13, 10.3.5

Type: Bug Priority: Blocker
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: corruption, foreign-keys, lock, transactions

Issue Links:
Blocks
blocks MDEV-14222 Unnecessary 'cascade' memory allocati... Closed
blocks MDEV-15199 Triangular FKs - Cascade delete cause... Closed
Problem/Incident
is caused by MDEV-13331 FK DELETE CASCADE does not honor inno... Closed
Relates
relates to MDEV-17541 KILL QUERY during lock wait in FOREIG... Closed

 Description   

If a lock wait occurs during the processing of a FOREIGN KEY constraint, InnoDB will fail to resume the FOREIGN KEY operation once the conflicting lock has been released.

The problem was introduced in MDEV-13331, in the function row_ins_check_foreign_constraint():

		err = check_table->to_be_dropped
			? DB_LOCK_WAIT_TIMEOUT
			: trx->error_state;

We should not assign other values than DB_LOCK_WAIT_TIMEOUT to err here. The following code works both for innodb.foreign_keys and the MySQL 5.7 test innodb.update-cascade which had been missing from MariaDB:

		if (check_table->to_be_dropped
		    || trx->error_state == DB_LOCK_WAIT_TIMEOUT) {
			err = DB_LOCK_WAIT_TIMEOUT;
		}


Generated at Thu Feb 08 08:19:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.