|
| 1 | +drop table if exists gh_ost_test; |
| 2 | +create table gh_ost_test ( |
| 3 | + id int auto_increment, |
| 4 | + email varchar(255) not null, |
| 5 | + primary key (id) |
| 6 | +) auto_increment=1; |
| 7 | + |
| 8 | +-- Insert initial data - all unique emails |
| 9 | +insert into gh_ost_test (email) values ( '[email protected]'); |
| 10 | +insert into gh_ost_test (email) values ( '[email protected]'); |
| 11 | +insert into gh_ost_test (email) values ( '[email protected]'); |
| 12 | + |
| 13 | +-- Create an event that fires once, 2 seconds after creation |
| 14 | +-- By then gh-ost will have started and the binlog reader will be active |
| 15 | +-- The event generates 3 INSERTs that will be batched during binlog replay: |
| 16 | +-- 1. INSERT with duplicate PRIMARY KEY (id=1) - warning on migration key (filtered) |
| 17 | +-- 2. INSERT with duplicate email - warning on new unique index (should FAIL) |
| 18 | +-- 3. INSERT with valid data - would succeed if not for #2 |
| 19 | +drop event if exists gh_ost_test; |
| 20 | +delimiter ;; |
| 21 | +create event gh_ost_test |
| 22 | + on schedule at current_timestamp + interval 2 second |
| 23 | + on completion not preserve |
| 24 | + enable |
| 25 | + do |
| 26 | +begin |
| 27 | + -- This creates the critical test scenario: |
| 28 | + -- Multiple DML events that will be batched together during binlog replay |
| 29 | + insert ignore into gh_ost_test (id, email) values ( 1, '[email protected]'); -- ignored on primary db, gh-ost doesn't see |
| 30 | + insert ignore into gh_ost_test (email) values ( '[email protected]'); -- ok on primary db, should trigger warning on gh-ost due to duplicate email |
| 31 | + insert ignore into gh_ost_test (email) values (concat('new', unix_timestamp(), '@example.com')); -- succeeds on both |
| 32 | +end ;; |
0 commit comments