Skip to content

Commit 560b69d

Browse files
committed
More robust test fix
1 parent 679115a commit 560b69d

2 files changed

Lines changed: 5 additions & 21 deletions

File tree

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

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ 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 enough rows to give a window for the event to fire
13-
-- With chunk-size=10, 100 rows = 10 chunks
14-
insert into gh_ost_test (email)
15-
select concat('user', @row := @row + 1, '@example.com')
16-
from (select @row := 3) init,
17-
(select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t1,
18-
(select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2
19-
limit 100;
20-
2112
drop event if exists gh_ost_test;
2213
delimiter ;;
2314
create event gh_ost_test
@@ -28,15 +19,9 @@ create event gh_ost_test
2819
enable
2920
do
3021
begin
31-
-- Poll for row copy to complete by checking if last row has been copied
32-
-- Once row copy is done but before cutover, fire the UPDATE that creates a duplicate
33-
-- Check a flag table to ensure we only fire once
34-
if exists (select 1 from test._gh_ost_test_gho where id >= 100)
35-
and not exists (select 1 from information_schema.tables where table_schema='test' and table_name='_gh_ost_fired') then
36-
create table test._gh_ost_fired (id int);
37-
-- This UPDATE modifies the primary key, so it will be converted to DELETE + INSERT
38-
-- The INSERT will attempt to insert email='alice@example.com' (duplicate)
39-
-- which violates the new unique index being added by the migration
40-
update gh_ost_test set id=200, email='alice@example.com' where id=2;
41-
end if;
22+
-- Keep inserting rows, then updating their PK to create DELETE+INSERT binlog events
23+
-- Use alice's email so it conflicts with id=1 when applied to ghost table
24+
insert ignore into gh_ost_test (email) values ('temp@example.com');
25+
update gh_ost_test set id = 1000 + id, email = 'alice@example.com'
26+
where email = 'temp@example.com' order by id desc limit 1;
4227
end ;;

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

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)