Skip to content

Commit 5217ba6

Browse files
committed
Reduce flakiness in update-pk test
1 parent 06df80d commit 5217ba6

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

  • localtests/panic-on-warnings-update-pk-with-duplicate-on-new-unique-index

localtests/panic-on-warnings-update-pk-with-duplicate-on-new-unique-index/create.sql

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,42 @@ insert into gh_ost_test (email) values ('alice@example.com');
99
insert into gh_ost_test (email) values ('bob@example.com');
1010
insert into gh_ost_test (email) values ('charlie@example.com');
1111

12+
-- Add more rows to extend row copy duration
13+
-- With chunk-size=10, 50 rows will take ~5 chunks giving the event time to detect and fire
14+
insert into gh_ost_test (email) values
15+
('user4@example.com'), ('user5@example.com'), ('user6@example.com'),
16+
('user7@example.com'), ('user8@example.com'), ('user9@example.com'),
17+
('user10@example.com'), ('user11@example.com'), ('user12@example.com'),
18+
('user13@example.com'), ('user14@example.com'), ('user15@example.com'),
19+
('user16@example.com'), ('user17@example.com'), ('user18@example.com'),
20+
('user19@example.com'), ('user20@example.com'), ('user21@example.com'),
21+
('user22@example.com'), ('user23@example.com'), ('user24@example.com'),
22+
('user25@example.com'), ('user26@example.com'), ('user27@example.com'),
23+
('user28@example.com'), ('user29@example.com'), ('user30@example.com'),
24+
('user31@example.com'), ('user32@example.com'), ('user33@example.com'),
25+
('user34@example.com'), ('user35@example.com'), ('user36@example.com'),
26+
('user37@example.com'), ('user38@example.com'), ('user39@example.com'),
27+
('user40@example.com'), ('user41@example.com'), ('user42@example.com'),
28+
('user43@example.com'), ('user44@example.com'), ('user45@example.com'),
29+
('user46@example.com'), ('user47@example.com'), ('user48@example.com'),
30+
('user49@example.com'), ('user50@example.com');
31+
1232
drop event if exists gh_ost_test;
1333
delimiter ;;
1434
create event gh_ost_test
1535
on schedule every 1 second
16-
starts current_timestamp + interval 3 second
36+
starts current_timestamp
1737
ends current_timestamp + interval 60 second
1838
on completion not preserve
1939
enable
2040
do
2141
begin
22-
-- This UPDATE modifies the primary key, so it will be converted to DELETE + INSERT
23-
-- The INSERT will attempt to insert email='alice@example.com' (duplicate)
24-
-- which violates the new unique index being added by the migration
25-
-- Delay ensures this fires during binlog apply phase, not bulk copy
26-
update gh_ost_test set id=10, email='alice@example.com' where id=2;
42+
-- Poll for row copy to start by checking if alice has been copied to ghost table
43+
-- Once row copy has started, fire the UPDATE that creates a duplicate
44+
if exists (select 1 from test._gh_ost_test_gho where email = 'alice@example.com') then
45+
-- This UPDATE modifies the primary key, so it will be converted to DELETE + INSERT
46+
-- The INSERT will attempt to insert email='alice@example.com' (duplicate)
47+
-- which violates the new unique index being added by the migration
48+
update gh_ost_test set id=10, email='alice@example.com' where id=2;
49+
end if;
2750
end ;;

0 commit comments

Comments
 (0)