Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Searched open issues for:
prepared foreign key cascade hang"PREPARE" "foreign key""ON UPDATE CASCADE" "prepared""ON DELETE SET NULL" "prepared"
No matching open issue was found.
Branch Name
main
Commit ID
51656deb6003
Other Environment Information
- MatrixOne:
select version()returns8.0.30-MatrixOne-v1.3.0 - MySQL comparison:
8.0.45 - Tested through the MySQL client with server-side prepared statements.
Actual Behavior
A prepared DML statement that triggers a foreign-key action hangs on the second EXECUTE.
Observed cases:
-
ON UPDATE CASCADEwith a composite foreign key:- First
EXECUTEupdates parent(1,'a1') -> (1,'a1x')and cascades to child rows. - Second
EXECUTEfor parent(2,'b1') -> (2,'b1x')does not return within 30 seconds. - After killing only the mysql client, the data remains at the state after the first execute:
(2,'b1')is unchanged in both parent and child tables.
- First
-
ON DELETE SET NULL:- First
EXECUTEdeletes parent100and sets childparent_idtoNULL. - Second
EXECUTEfor parent200does not return within 30 seconds. - After killing only the mysql client, parent
200and its child reference remain unchanged.
- First
Control checks on the same MatrixOne build:
- The same
ON UPDATE CASCADEstatements executed as normal SQL literals finish successfully. - The same
ON DELETE SET NULLstatements executed as normal SQL literals finish successfully. - The prepared hang still reproduces when the second parameter uses the same integer type, so this is not only a string-to-int coercion issue.
Expected Behavior
Same as MySQL: repeated EXECUTE of the prepared statement should finish normally, and each foreign-key action should be applied.
For ON UPDATE CASCADE, MySQL returns:
tenant acct status
1 a1x open
2 b1x hold
tenant acct child_id note
1 a1x 10 c-a1-10
2 b1x 20 c-b1-20
For ON DELETE SET NULL, MySQL returns:
child_id parent_id note
1 NULL s100-a
2 NULL s200-a
Steps to Reproduce
Case 1: prepared parent update with ON UPDATE CASCADE
drop database if exists mysql_compat_model14_prepare_fk_upd_same_type;
create database mysql_compat_model14_prepare_fk_upd_same_type;
use mysql_compat_model14_prepare_fk_upd_same_type;
create table parent_cascade (
tenant int not null,
acct varchar(20) not null,
status varchar(10),
primary key (tenant, acct)
);
create table child_cascade (
tenant int not null,
acct varchar(20) not null,
child_id int not null,
note varchar(30),
primary key (tenant, acct, child_id),
constraint fk_child_cascade foreign key (tenant, acct)
references parent_cascade(tenant, acct)
on update cascade
on delete cascade
);
insert into parent_cascade values (1,'a1','open'),(2,'b1','hold');
insert into child_cascade values (1,'a1',10,'c-a1-10'),(2,'b1',20,'c-b1-20');
prepare s_parent_upd from 'update parent_cascade set acct = ? where tenant = ? and acct = ?';
set @new_acct='a1x', @tenant=1, @old_acct='a1';
execute s_parent_upd using @new_acct,@tenant,@old_acct;
set @new_acct='b1x', @tenant=2, @old_acct='b1';
execute s_parent_upd using @new_acct,@tenant,@old_acct;The second execute hangs on MatrixOne.
Case 2: prepared parent delete with ON DELETE SET NULL
drop database if exists mysql_compat_model14_prepare_fk_same_type;
create database mysql_compat_model14_prepare_fk_same_type;
use mysql_compat_model14_prepare_fk_same_type;
create table parent_setnull (
id int primary key,
code varchar(20) unique
);
create table child_setnull (
child_id int primary key,
parent_id int,
note varchar(30),
key idx_parent(parent_id, note),
constraint fk_child_setnull foreign key (parent_id)
references parent_setnull(id)
on delete set null
);
insert into parent_setnull values (100,'p100'),(200,'p200');
insert into child_setnull values (1,100,'s100-a'),(2,200,'s200-a');
prepare s_parent_del from 'delete from parent_setnull where id = ?';
set @pid=100;
execute s_parent_del using @pid;
set @pid=200;
execute s_parent_del using @pid;The second execute hangs on MatrixOne.
Additional information
This was found during MySQL compatibility exploration for prepared statements with composite primary keys / foreign keys / secondary indexes. The behavior is important for BVT unhappy-path coverage because normal non-prepared SQL works while repeated prepared execution does not.
Activity
LeftHandCold commentedon Jul 13, 2026
fixed
Ariznawlll commentedon Jul 13, 2026
已在最新
main上完成验证,并补充 motr 回归测试。验证环境
main@52afd25fa63a3cb6037b7bf8ff0bf1328c4793ecissue_25419_prepared_fk_actions测试过程
分别验证两个外键动作路径:
ON UPDATE CASCADE;ON DELETE SET NULL。每个 prepared statement 都执行三次:第一次命中并触发外键动作,中间一次不命中任何行,第三次再次命中并触发外键动作。同时将每个父行扩展为关联多个子行,最后查询父表和子表确认全部级联结果。
验证结果
EXECUTE均正常返回,没有再次出现第二次执行卡住。