Skip to content

Commit

Permalink
fix(tianmu):Master slave synchronization, primary key scanning failed(#…
Browse files Browse the repository at this point in the history
…1174)

There is a problem with the judgment condition. You cannot ignore the case where the primary key value is 0
  • Loading branch information
konghaiya authored and mergify[bot] committed Jan 3, 2023
1 parent e5efa89 commit 0bc2cbe
Show file tree
Hide file tree
Showing 3 changed files with 504 additions and 1 deletion.
303 changes: 303 additions & 0 deletions mysql-test/suite/tianmu/r/issue1174.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
use test;
drop table if exists `ttt`;
drop table if exists `t3`;
include/master-slave.inc
[connection master]
#
# Has primary key
#
[on master]
create table ttt(id int primary key,name varchar(64))engine=innodb;
insert into ttt values(111,'你好');
insert into ttt values(11,'aaa');
insert into ttt values(3,'hhhb');
insert into ttt values(2,'hhhb');
insert into ttt values(1,'hhhb');
insert into ttt values(0,'hhhb');
insert into ttt values(31,'hhhb');
insert into ttt values(32,'zzz');
insert into ttt values(4,'hhhb');
insert into ttt values(5,'zzz');
insert into ttt values(6,'hhhb');
insert into ttt values(7,'zzz');
insert into ttt values(88,'hhhb');
insert into ttt values(98,'zzz');
update ttt set name='lllll' where id in(1,3,2,0);
select * from ttt where id in(1,3,2,0) order by id desc;
id name
3 lllll
2 lllll
1 lllll
0 lllll
[on slave]
include/sync_slave_sql_with_master.inc
select * from ttt where id in(1,3,2,0) order by id desc;
id name
3 lllll
2 lllll
1 lllll
0 lllll
[on master]
delete from ttt where id=1;
delete from ttt where id=0;
delete from ttt where name='zzz';
select * from ttt order by id desc;
id name
111 你好
88 hhhb
31 hhhb
11 aaa
6 hhhb
4 hhhb
3 lllll
2 lllll
[on slave]
include/sync_slave_sql_with_master.inc
select * from ttt order by id desc;
id name
111 你好
88 hhhb
31 hhhb
11 aaa
6 hhhb
4 hhhb
3 lllll
2 lllll
[on master]
drop table ttt;
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b))engine=innodb;
insert into t3 values (1,1),(2,1),(1,3),(4,5),(6,7),(8,9),(0,0);
delete from t3 where a in (4,6,1,0);
select * from t3 order by a desc;
a b
8 9
2 1
[on slave]
include/sync_slave_sql_with_master.inc
select * from t3 order by a desc;
a b
8 9
2 1
[on master]
drop table t3;
include/sync_slave_sql_with_master.inc
#
# Have unique constraints
#
[on master]
create table ttt(id int NOT NULL UNIQUE,name varchar(64))engine=innodb;
insert into ttt values(111,'你好');
insert into ttt values(11,'aaa');
insert into ttt values(3,'hhhb');
insert into ttt values(2,'hhhb');
insert into ttt values(1,'hhhb');
insert into ttt values(0,'hhhb');
insert into ttt values(31,'hhhb');
insert into ttt values(32,'zzz');
insert into ttt values(4,'hhhb');
insert into ttt values(5,'zzz');
insert into ttt values(6,'hhhb');
insert into ttt values(7,'zzz');
insert into ttt values(88,'hhhb');
insert into ttt values(98,'zzz');
update ttt set name='lllll' where id in(1,3,2,0);
select * from ttt where id in(1,3,2,0) order by id desc;
id name
3 lllll
2 lllll
1 lllll
0 lllll
[on slave]
include/sync_slave_sql_with_master.inc
select * from ttt where id in(1,3,2,0) order by id desc;
id name
3 lllll
2 lllll
1 lllll
0 lllll
[on master]
delete from ttt where id=1;
delete from ttt where id=0;
delete from ttt where name='zzz';
select * from ttt order by id desc;
id name
111 你好
88 hhhb
31 hhhb
11 aaa
6 hhhb
4 hhhb
3 lllll
2 lllll
[on slave]
include/sync_slave_sql_with_master.inc
select * from ttt order by id desc;
id name
111 你好
88 hhhb
31 hhhb
11 aaa
6 hhhb
4 hhhb
3 lllll
2 lllll
[on master]
drop table ttt;
CREATE TABLE t3 (a int not null, b int not null, UNIQUE(a,b))engine=innodb;
insert into t3 values (1,1),(2,1),(1,3),(4,5),(6,7),(8,9),(0,0);
delete from t3 where a in (4,6,1,0);
select * from t3 order by a desc;
a b
8 9
2 1
[on slave]
include/sync_slave_sql_with_master.inc
select * from t3 order by a desc;
a b
8 9
2 1
[on master]
drop table t3;
include/sync_slave_sql_with_master.inc
#
# With secondary index
#
[on master]
create table ttt(id int not null,name varchar(64),index(id))engine=innodb;
insert into ttt values(111,'你好');
insert into ttt values(11,'aaa');
insert into ttt values(3,'hhhb');
insert into ttt values(2,'hhhb');
insert into ttt values(1,'hhhb');
insert into ttt values(0,'hhhb');
insert into ttt values(31,'hhhb');
insert into ttt values(32,'zzz');
insert into ttt values(4,'hhhb');
insert into ttt values(5,'zzz');
insert into ttt values(6,'hhhb');
insert into ttt values(7,'zzz');
insert into ttt values(88,'hhhb');
insert into ttt values(98,'zzz');
update ttt set name='lllll' where id in(1,3,2,0);
select * from ttt where id in(1,3,2,0) order by id desc;
id name
3 lllll
2 lllll
1 lllll
0 lllll
[on slave]
include/sync_slave_sql_with_master.inc
select * from ttt where id in(1,3,2,0) order by id desc;
id name
3 lllll
2 lllll
1 lllll
0 lllll
[on master]
delete from ttt where id=1;
delete from ttt where id=0;
delete from ttt where name='zzz';
select * from ttt order by id desc;
id name
111 你好
88 hhhb
31 hhhb
11 aaa
6 hhhb
4 hhhb
3 lllll
2 lllll
[on slave]
include/sync_slave_sql_with_master.inc
select * from ttt order by id desc;
id name
111 你好
88 hhhb
31 hhhb
11 aaa
6 hhhb
4 hhhb
3 lllll
2 lllll
[on master]
drop table ttt;
CREATE TABLE t3 (a int not null, b int not null, index(a,b))engine=innodb;
insert into t3 values (1,1),(2,1),(1,3),(4,5),(6,7),(8,9),(0,0);
delete from t3 where a in (4,6,1,0);
select * from t3 order by a desc;
a b
8 9
2 1
[on slave]
include/sync_slave_sql_with_master.inc
select * from t3 order by a desc;
a b
8 9
2 1
[on master]
drop table t3;
include/sync_slave_sql_with_master.inc
#
# common
#
[on master]
create table ttt(id int , name varchar(64))engine=innodb;
insert into ttt values(111,'你好');
insert into ttt values(11,'aaa');
insert into ttt values(3,'hhhb');
insert into ttt values(2,'hhhb');
insert into ttt values(1,'hhhb');
insert into ttt values(0,'hhhb');
insert into ttt values(31,'hhhb');
insert into ttt values(32,'zzz');
insert into ttt values(4,'hhhb');
insert into ttt values(5,'zzz');
insert into ttt values(6,'hhhb');
insert into ttt values(7,'zzz');
insert into ttt values(88,'hhhb');
insert into ttt values(98,'zzz');
update ttt set name='lllll' where id in(1,3,2,0);
select * from ttt where id in(1,3,2,0) order by id desc;
id name
3 lllll
2 lllll
1 lllll
0 lllll
[on slave]
include/sync_slave_sql_with_master.inc
select * from ttt where id in(1,3,2,0) order by id desc;
id name
3 lllll
2 lllll
1 lllll
0 lllll
[on master]
delete from ttt where id=1;
delete from ttt where id=0;
delete from ttt where name='zzz';
select * from ttt order by id desc;
id name
111 你好
88 hhhb
31 hhhb
11 aaa
6 hhhb
4 hhhb
3 lllll
2 lllll
[on slave]
include/sync_slave_sql_with_master.inc
select * from ttt order by id desc;
id name
111 你好
88 hhhb
31 hhhb
11 aaa
6 hhhb
4 hhhb
3 lllll
2 lllll
[on master]
drop table ttt;
include/sync_slave_sql_with_master.inc
stop slave;

0 comments on commit 0bc2cbe

Please sign in to comment.