-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tianm): fix problems related to master slave synchronization (#819)
fix 1:#818 Master slave synchronization - There will be too many tuples problem Cause: Tianmu::dbhandler::TianmuHandler::current_position This variable is not initialized. In some cases, a large value may cause too many tuples problem. Solution: Initialize the variable fix 2:#819 Master slave synchronization - Primary key conflict problem Solution: Modify the modification logic of master slave synchronization, so that the delete and update operations do not follow the primary key logic Supplement sql/sql_insert.cc Fix the problem that the insert statement will not generate binlog in the delayed insert mode storage/tianmu/handler/tianmu_handler.cpp Fix the binlog error of the line format generated by the tianmu engine
- Loading branch information
Showing
6 changed files
with
513 additions
and
28 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,234 @@ | ||
include/master-slave.inc | ||
[connection master] | ||
# | ||
# Test the master-slave function of innodb | ||
# | ||
# connection master | ||
use test; | ||
create table ttt(id int primary key,name varchar(5))engine=innodb; | ||
insert into ttt values(1,'AAA'); | ||
delete from ttt where id=1; | ||
insert into ttt values(1,'aaa'); | ||
select * from ttt; | ||
id name | ||
1 aaa | ||
# connection slave | ||
include/sync_slave_sql_with_master.inc | ||
select * from ttt; | ||
id name | ||
1 aaa | ||
# connection master | ||
drop table ttt; | ||
include/sync_slave_sql_with_master.inc | ||
# connection master | ||
CREATE TABLE t1 (a int not null,b int not null)engine=innodb; | ||
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b))engine=innodb; | ||
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b))engine=innodb; | ||
insert into t1 values (1,1),(2,1),(1,3); | ||
insert into t2 values (1,1),(2,2),(3,3); | ||
insert into t3 values (1,1),(2,1),(1,3); | ||
delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; | ||
select * from t1; | ||
a b | ||
1 1 | ||
2 1 | ||
1 3 | ||
select * from t2; | ||
a b | ||
3 3 | ||
select * from t3; | ||
a b | ||
# connection slave | ||
include/sync_slave_sql_with_master.inc | ||
select * from t1; | ||
a b | ||
1 1 | ||
2 1 | ||
1 3 | ||
select * from t2; | ||
a b | ||
3 3 | ||
select * from t3; | ||
a b | ||
# connection master | ||
drop table t1,t2,t3; | ||
include/sync_slave_sql_with_master.inc | ||
# connection master | ||
CREATE TABLE t1 | ||
( | ||
place_id int (10) unsigned NOT NULL, | ||
shows int(10) unsigned DEFAULT '0' NOT NULL, | ||
ishows int(10) unsigned DEFAULT '0' NOT NULL, | ||
ushows int(10) unsigned DEFAULT '0' NOT NULL, | ||
clicks int(10) unsigned DEFAULT '0' NOT NULL, | ||
iclicks int(10) unsigned DEFAULT '0' NOT NULL, | ||
uclicks int(10) unsigned DEFAULT '0' NOT NULL, | ||
ts timestamp, | ||
PRIMARY KEY (place_id,ts) | ||
)engine=innodb; | ||
INSERT INTO t1 (place_id,shows,ishows,ushows,clicks,iclicks,uclicks,ts) | ||
VALUES (1,0,0,0,0,0,0,20000928174434); | ||
UPDATE t1 SET shows=shows+1,ishows=ishows+1,ushows=ushows+1,clicks=clicks+1,iclicks=iclicks+1,uclicks=uclicks+1 WHERE place_id=1 AND ts>="2000-09-28 00:00:00"; | ||
select place_id,shows from t1; | ||
place_id shows | ||
1 1 | ||
# connection slave | ||
include/sync_slave_sql_with_master.inc | ||
select place_id,shows from t1; | ||
place_id shows | ||
1 1 | ||
# connection master | ||
drop table t1; | ||
include/sync_slave_sql_with_master.inc | ||
# | ||
# Test the master-slave function of tianmu | ||
# | ||
# connection master | ||
use test; | ||
create table ttt(id int primary key,name varchar(5))engine=tianmu; | ||
insert into ttt values(1,'AAA'); | ||
update ttt set name='hhhh' where id=1; | ||
select * from ttt; | ||
id name | ||
1 hhhh | ||
# connection slave | ||
include/sync_slave_sql_with_master.inc | ||
select * from ttt; | ||
id name | ||
1 hhhh | ||
# connection master | ||
drop table ttt; | ||
include/sync_slave_sql_with_master.inc | ||
# connection master | ||
create table t1(id int primary key,name varchar(5))engine=tianmu; | ||
insert into t1 values(1,'AAA'); | ||
delete from t1 where id=1; | ||
insert into t1 values(1,'aaa'); | ||
select * from t1; | ||
id name | ||
1 aaa | ||
# connection slave | ||
include/sync_slave_sql_with_master.inc | ||
select * from t1; | ||
id name | ||
1 aaa | ||
# connection master | ||
drop table t1; | ||
CREATE TABLE t1 (a int not null,b int not null)engine=tianmu; | ||
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b))engine=tianmu; | ||
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b))engine=tianmu; | ||
insert into t1 values (1,1),(2,1),(1,3); | ||
insert into t2 values (1,1),(2,2),(3,3); | ||
insert into t3 values (1,1),(2,1),(1,3); | ||
delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; | ||
select * from t1; | ||
a b | ||
1 1 | ||
2 1 | ||
1 3 | ||
select * from t2; | ||
a b | ||
3 3 | ||
select * from t3; | ||
a b | ||
# connection slave | ||
include/sync_slave_sql_with_master.inc | ||
select * from t1; | ||
a b | ||
1 1 | ||
2 1 | ||
1 3 | ||
select * from t2; | ||
a b | ||
3 3 | ||
select * from t3; | ||
a b | ||
# connection master | ||
drop table t1,t2,t3; | ||
include/sync_slave_sql_with_master.inc | ||
# connection master | ||
CREATE TABLE t1 | ||
( | ||
place_id int (10), | ||
shows int(10), | ||
ishows int(10), | ||
ushows int(10), | ||
clicks int(10), | ||
iclicks int(10), | ||
uclicks int(10), | ||
ts timestamp, | ||
PRIMARY KEY (place_id,ts) | ||
)engine=tianmu; | ||
INSERT INTO t1 (place_id,shows,ishows,ushows,clicks,iclicks,uclicks,ts) | ||
VALUES (1,0,0,0,0,0,0,20000928174434); | ||
UPDATE t1 SET shows=shows+1,ishows=ishows+1,ushows=ushows+1,clicks=clicks+1,iclicks=iclicks+1,uclicks=uclicks+1 WHERE place_id=1 AND ts>="2000-09-28 00:00:00"; | ||
select place_id,shows from t1; | ||
place_id shows | ||
1 1 | ||
# connection slave | ||
include/sync_slave_sql_with_master.inc | ||
select place_id,shows from t1; | ||
place_id shows | ||
1 1 | ||
# connection master | ||
drop table t1; | ||
create table t1 (s1 int); | ||
create table t2 (s2 int); | ||
insert into t1 values (1), (2); | ||
insert into t2 values (2), (3); | ||
create view v1 as select * from t1,t2 union all select * from t1,t2; | ||
select * from v1; | ||
s1 s2 | ||
1 2 | ||
2 2 | ||
1 3 | ||
2 3 | ||
1 2 | ||
2 2 | ||
1 3 | ||
2 3 | ||
# connection slave | ||
include/sync_slave_sql_with_master.inc | ||
select * from v1; | ||
s1 s2 | ||
1 2 | ||
2 2 | ||
1 3 | ||
2 3 | ||
1 2 | ||
2 2 | ||
1 3 | ||
2 3 | ||
# connection master | ||
drop view v1; | ||
drop tables t1, t2; | ||
create table t1 (col1 int); | ||
insert into t1 values (1); | ||
create view v1 as select count(*) from t1; | ||
insert into t1 values (null); | ||
select * from v1; | ||
count(*) | ||
2 | ||
# connection slave | ||
include/sync_slave_sql_with_master.inc | ||
select * from v1; | ||
count(*) | ||
2 | ||
# connection master | ||
drop view v1; | ||
drop table t1; | ||
create table t1 (a int); | ||
create table t2 (a int); | ||
create view v1 as select a from t1; | ||
create view v2 as select a from t2 where a in (select a from v1); | ||
show create view v2; | ||
View Create View character_set_client collation_connection | ||
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where `t2`.`a` in (select `v1`.`a` from `v1`) latin1 latin1_swedish_ci | ||
# connection slave | ||
include/sync_slave_sql_with_master.inc | ||
show create view v2; | ||
View Create View character_set_client collation_connection | ||
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where `t2`.`a` in (select `v1`.`a` from `v1`) latin1 latin1_swedish_ci | ||
# connection master | ||
drop view v2, v1; | ||
drop table t1, t2; |
Oops, something went wrong.