forked from stoneatom/stonedb
-
Notifications
You must be signed in to change notification settings - Fork 0
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 (sto…
…neatom#819) 1. sql/sql_insert.cc Fix the problem that the insert statement will not generate binlog in the delayed insert mode 2. storage/tianmu/handler/tianmu_handler.cpp Fix the binlog error of the line format generated by the tianmu engine
- Loading branch information
Showing
5 changed files
with
415 additions
and
48 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,177 @@ | ||
include/master-slave.inc | ||
Warnings: | ||
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. | ||
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. | ||
[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; |
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,170 @@ | ||
-- source include/have_tianmu.inc | ||
-- source include/master-slave.inc | ||
|
||
--echo # | ||
--echo # Test the master-slave function of innodb | ||
--echo # | ||
|
||
--echo # connection master | ||
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; | ||
|
||
--echo # connection slave | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
select * from ttt; | ||
|
||
--echo # connection master | ||
connection master; | ||
drop table ttt; | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
--echo # connection master | ||
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; | ||
select * from t2; | ||
select * from t3; | ||
|
||
--echo # connection slave | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
select * from t1; | ||
select * from t2; | ||
select * from t3; | ||
|
||
--echo # connection master | ||
connection master; | ||
drop table t1,t2,t3; | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
--echo # connection master | ||
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; | ||
|
||
--echo # connection slave | ||
--source include/sync_slave_sql_with_master.inc | ||
select place_id,shows from t1; | ||
|
||
--echo # connection master | ||
connection master; | ||
drop table t1; | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
--echo # | ||
--echo # Test the master-slave function of tianmu | ||
--echo # | ||
|
||
--echo # connection master | ||
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; | ||
|
||
--echo # connection slave | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
select * from ttt; | ||
|
||
--echo # connection master | ||
connection master; | ||
drop table ttt; | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
--echo # connection master | ||
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; | ||
|
||
--echo # connection slave | ||
--source include/sync_slave_sql_with_master.inc | ||
select * from t1; | ||
|
||
--echo # connection master | ||
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; | ||
select * from t2; | ||
select * from t3; | ||
|
||
--echo # connection slave | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
select * from t1; | ||
select * from t2; | ||
select * from t3; | ||
|
||
--echo # connection master | ||
connection master; | ||
drop table t1,t2,t3; | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
--echo # connection master | ||
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; | ||
|
||
--echo # connection slave | ||
--source include/sync_slave_sql_with_master.inc | ||
select place_id,shows from t1; | ||
|
||
--echo # connection master | ||
connection master; | ||
drop table t1; |
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
Oops, something went wrong.