Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
MDEV-16690 node hang due to conflicting inserts in FK child table
Add the test case. The actual bug was fixed in MDEV-17541. Closes #811
- Loading branch information
Showing
2 changed files
with
541 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,380 @@ | ||
| CREATE TABLE user(id int primary key, j int) ENGINE=InnoDB; | ||
| CREATE TABLE user_session(id int primary key, fk1 int, fk2 int) ENGINE=InnoDB; | ||
| alter table user_session add foreign key (fk1) references user(id); | ||
| INSERT INTO user values (1,0), (2,0), (3,0), (4,0); | ||
| INSERT INTO user_session values (1,1,1); | ||
| connect node_1_u, 127.0.0.1, root, , test, $NODE_MYPORT_1; | ||
| connect node_1_i, 127.0.0.1, root, , test, $NODE_MYPORT_1; | ||
| connect node_2_i, 127.0.0.1, root, , test, $NODE_MYPORT_2; | ||
| "Phase 1: plain SQL statements" | ||
| connection node_1; | ||
| connection node_1_u; | ||
| begin; | ||
| update user set j = j + 1 WHERE id > 0; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 2); | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 3); | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| update user set j = j + 1 WHERE id > 0; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 2); | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 3); | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| update user set j = j + 1 WHERE id > 0; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 2); | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 3); | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| update user set j = j + 1 WHERE id > 0; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 2); | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 3); | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| update user set j = j + 1 WHERE id > 0; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 2); | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 3); | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| update user set j = j + 1 WHERE id > 0; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 2); | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 3); | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| update user set j = j + 1 WHERE id > 0; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 2); | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 3); | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| update user set j = j + 1 WHERE id > 0; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 2); | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 3); | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| update user set j = j + 1 WHERE id > 0; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 2); | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 3); | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| update user set j = j + 1 WHERE id > 0; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 2); | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| insert into user_session(id,fk1,fk2) values (2, 2, 3); | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| "Phase 2: prepared statements" | ||
| connection node_1_u; | ||
| prepare upd from 'update user set j = j + 1 WHERE id > 0'; | ||
| connection node_1_i; | ||
| prepare ins1 from 'insert into user_session(id,fk1,fk2) values (2, 2, 2)'; | ||
| connection node_2_i; | ||
| prepare ins2 from 'insert into user_session(id,fk1,fk2) values (2, 2, 3)'; | ||
| connection node_1; | ||
| connection node_1_u; | ||
| begin; | ||
| execute upd; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| execute ins1; | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| execute ins2; | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| execute upd; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| execute ins1; | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| execute ins2; | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| execute upd; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| execute ins1; | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| execute ins2; | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| execute upd; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| execute ins1; | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| execute ins2; | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| execute upd; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| execute ins1; | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| execute ins2; | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| execute upd; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| execute ins1; | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| execute ins2; | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| execute upd; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| execute ins1; | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| execute ins2; | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| execute upd; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| execute ins1; | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| execute ins2; | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| execute upd; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| execute ins1; | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| execute ins2; | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1_u; | ||
| begin; | ||
| execute upd; | ||
| connection node_1_i; | ||
| set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; | ||
| execute ins1; | ||
| connection node_1; | ||
| set debug_sync='now WAIT_FOR ins_waiting'; | ||
| connection node_2_i; | ||
| execute ins2; | ||
| connection node_1; | ||
| set debug_sync='now SIGNAL cont_ins'; | ||
| connection node_1_i; | ||
| connection node_1_u; | ||
| commit; | ||
| connection node_1; | ||
| truncate user_session; | ||
| set debug_sync = reset; | ||
| connection node_1; | ||
| drop table user_session,user; |
Oops, something went wrong.