← Back
Editing: ndb_rpl_conflict_epoch_extended_exceptions_table.test
# # Test engine native conflict resolution for ndb # NDB$EPOCH_TRANS() function # # --source include/have_utf8.inc --source include/have_ndb.inc --source include/have_binlog_format_mixed_or_row.inc --source suite/ndb_rpl/ndb_master-slave.inc --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc --echo Setup circular replication --connection slave RESET MASTER; let $SLAVE_SERVER_ID= `select @@server_id`; echo SLAVE_SERVER_ID: $SLAVE_SERVER_ID; --connection master --replace_result $SLAVE_MYPORT SLAVE_PORT --eval CHANGE MASTER TO master_host="127.0.0.1",master_port=$SLAVE_MYPORT,master_user="root" START SLAVE; let $MASTER_SERVER_ID= `select @@server_id`; echo MASTER_SERVER_ID: $MASTER_SERVER_ID; --echo Setup ndb_replication and exceptions tables --disable_warnings --disable_query_log --connection master drop table if exists mysql.ndb_replication; CREATE TABLE mysql.ndb_replication (db VARBINARY(63), table_name VARBINARY(63), server_id INT UNSIGNED, binlog_type INT UNSIGNED, conflict_fn VARBINARY(128), PRIMARY KEY USING HASH (db,table_name,server_id)) ENGINE=NDB PARTITION BY KEY(db,table_name); --enable_warnings --enable_query_log --echo Populate ndb_replication table as necessary eval replace into mysql.ndb_replication values ("test", "t1", $SLAVE_SERVER_ID, 7, NULL), ("test", "t1", $MASTER_SERVER_ID, 7, "NDB\$EPOCH()"), ("test", "t2", $SLAVE_SERVER_ID, 7, NULL), ("test", "t2", $MASTER_SERVER_ID, 7, "NDB\$EPOCH_TRANS()"); # # Test illegal exception table definitions # call mtr.add_suppression("NDB Slave: exceptions table .* has wrong definition .*"); call mtr.add_suppression("Exceptions table *"); # Check that all mandatory columns need NDB$ suffix create table test.t1$EX (SERVER_ID int unsigned, NDB$MASTER_SERVER_ID int unsigned, NDB$MASTER_EPOCH bigint unsigned, NDB$COUNT int unsigned, a int not null, NDB$OP_TYPE ENUM('WRITE_ROW','UPDATE_ROW', 'DELETE_ROW') NOT NULL, NDB$CFT_CAUSE ENUM('ROW_DOES_NOT_EXIST','ROW_ALREADY_EXISTS','DATA_IN_CONFLICT','TRANS_IN_CONFLICT') NOT NULL, primary key(SERVER_ID, NDB$MASTER_SERVER_ID, NDB$MASTER_EPOCH, NDB$COUNT)) ENGINE=NDB; create table test.t1 ( a int not null, b int not null, c varchar(2000), primary key (a,b)) engine=ndb; --let server_num=1.1 --let $pattern=%Exceptions table % --let $limit=1 # Note warning is displayed in lower case, real warning is correct --source suite/ndb_rpl/t/show_mysqld_warnings.inc drop table test.t1$EX, test.t1; # Check that referencing old/new values of primary key is not supported create table test.t1$EX (NDB$SERVER_ID int unsigned, NDB$MASTER_SERVER_ID int unsigned, NDB$MASTER_EPOCH bigint unsigned, NDB$COUNT int unsigned, a$old int, a$new int, NDB$OP_TYPE ENUM('WRITE_ROW','UPDATE_ROW', 'DELETE_ROW') NOT NULL, NDB$CFT_CAUSE ENUM('ROW_DOES_NOT_EXIST','ROW_ALREADY_EXISTS','DATA_IN_CONFLICT','TRANS_IN_CONFLICT') NOT NULL, primary key(NDB$SERVER_ID, NDB$MASTER_SERVER_ID, NDB$MASTER_EPOCH, NDB$COUNT)) ENGINE=NDB; create table test.t1 ( a int not null, b int not null, c varchar(2000), primary key (a,b)) engine=ndb; --let server_num=1.1 --let $pattern=%Exceptions table % --let $limit=1 # Note warning is displayed in lower case, real warning is correct --source suite/ndb_rpl/t/show_mysqld_warnings.inc drop table test.t1$EX, test.t1; # Check that referencing old/new values allow for null values create table test.t1$EX (NDB$SERVER_ID int unsigned, NDB$MASTER_SERVER_ID int unsigned, NDB$MASTER_EPOCH bigint unsigned, NDB$COUNT int unsigned, c$old varchar(2000) not null, c$new varchar(2000) not null, NDB$OP_TYPE ENUM('WRITE_ROW','UPDATE_ROW', 'DELETE_ROW') NOT NULL, NDB$CFT_CAUSE ENUM('ROW_DOES_NOT_EXIST','ROW_ALREADY_EXISTS','DATA_IN_CONFLICT','TRANS_IN_CONFLICT') NOT NULL, primary key(NDB$SERVER_ID, NDB$MASTER_SERVER_ID, NDB$MASTER_EPOCH, NDB$COUNT)) ENGINE=NDB; create table test.t1 ( a int not null, b int not null, c varchar(2000), primary key (a,b)) engine=ndb; --let server_num=1.1 --let $pattern=%Exceptions table % --let $limit=1 # Note warning is displayed in lower case, real warning is correct --source suite/ndb_rpl/t/show_mysqld_warnings.inc drop table test.t1$EX, test.t1; create table test.t1$EX (NDB$SERVER_ID int unsigned, NDB$MASTER_SERVER_ID int unsigned, NDB$MASTER_EPOCH bigint unsigned, NDB$COUNT int unsigned, a int not null, NDB$OP_TYPE ENUM('WRITE_ROW','UPDATE_ROW', 'DELETE_ROW') NOT NULL, NDB$CFT_CAUSE ENUM('ROW_DOES_NOT_EXIST','ROW_ALREADY_EXISTS','DATA_IN_CONFLICT','TRANS_IN_CONFLICT') NOT NULL, primary key(NDB$SERVER_ID, NDB$MASTER_SERVER_ID, NDB$MASTER_EPOCH, NDB$COUNT)) ENGINE=NDB; create table test.t1 ( a int not null, b int not null, c varchar(2000), primary key (a,b)) engine=ndb; # # Test different column order than original table # for both primary key and non primary columns. # Test non primary key column declared not null, # but with a default value. # create table test.t2$ex (ndb$server_id int unsigned, ndb$master_server_id int unsigned, ndb$master_epoch bigint unsigned, ndb$count int unsigned, d varchar(2000), c int not null default 99, b int not null, a int not null, d$old varchar(2000), d$new varchar(2000), ndb$op_type enum('write_row','update_row', 'delete_row') not null, ndb$cft_cause enum('row_does_not_exist','row_already_exists','data_in_conflict','trans_in_conflict') not null, ndb$orig_transid bigint unsigned not null, e int, primary key(ndb$server_id, ndb$master_server_id, ndb$master_epoch, ndb$count)) engine=ndb; create table test.t2 ( x int default 21, a int not null, b int not null, c int, d varchar(2000), e int, primary key(a,b)) engine=ndb; --sync_slave_with_master slave --connection master --echo Add some data let $1=10; disable_query_log; while ($1) { eval insert into test.t1 values($1, $1+1, concat("Initial data ",$1)); eval insert into test.t2(a,b,c,d,e) values($1, $1+1, $1+2, concat("Initial data ",$1),17); dec $1; } enable_query_log; --sync_slave_with_master slave --connection slave stop slave; --connection slave --echo Slave contents select * from t1 order by a; select * from test.t2 order by a; --connection master let $1=10; disable_query_log; while ($1) { eval update test.t1 set c = concat("Master updated data ",$1) where a = $1; begin; eval update test.t2 set d = concat("Master updated data ",$1) where a = $1 and b = $1+1; commit; dec $1; } enable_query_log; --connection slave let $1=10; disable_query_log; while ($1) { eval update test.t1 set c = concat("Slave updated data ",$1) where a = $1; begin; eval update test.t2 set d = concat("Slave updated data ",$1) where a = $1 and b = $1+1; commit; dec $1; } enable_query_log; --connection master --echo Master contents select * from test.t1 order by a; select * from test.t2 order by a; --connection slave --echo Slave contents select * from test.t1 order by a; select * from test.t2 order by a; --sync_slave_with_master master --echo Primary should have rejected change from Secondary, keeping its value select * from t1 order by a; select * from t2 order by a; --connection slave start slave; --connection master --sync_slave_with_master slave --connection slave --echo Secondary should have been realigned to Primary --echo Slave contents select * from t1 order by a; select * from t2 order by a; --echo Show rollback of whole secondary transaction --echo -------------------------------------------- --connection slave flush logs; --sync_slave_with_master master --echo Slave contents select * from t1 order by a; select * from t2 order by a; --connection master select count(*) from t1$EX; select NDB$OP_TYPE,NDB$CFT_CAUSE from t1$EX order by a; select count(*) from t2$ex; select a, b, c, d, d$old, d$new, e, ndb$count > 0,ndb$op_type,ndb$cft_cause, ndb$orig_transid > 0 from t2$ex order by a; # # Test using table name and column names in utf8 # SET NAMES utf8; eval replace into mysql.ndb_replication values ("test", "アアア", $SLAVE_SERVER_ID, 7, NULL), ("test", "アアア", $MASTER_SERVER_ID, 7, "NDB\$EPOCH_TRANS()"); create table test.`アアア$ex` (ndb$server_id int unsigned, ndb$master_server_id int unsigned, ndb$master_epoch bigint unsigned, ndb$count int unsigned, `キキキ` varchar(2000) charset utf8, `カカカ` int not null, ndb$op_type enum('write_row','update_row', 'delete_row') not null, ndb$cft_cause enum('row_does_not_exist','row_already_exists','data_in_conflict','trans_in_conflict') not null, ndb$orig_transid bigint unsigned not null, primary key(ndb$server_id, ndb$master_server_id, ndb$master_epoch, ndb$count)) engine=ndb; create table test.`アアア` ( `カカカ` int primary key, `キキキ` varchar(2000) charset utf8) engine=ndb; SET NAMES latin1; --let $pattern=%suspicious % column op_type % --let $limit=1 --source suite/ndb_rpl/t/show_mysqld_warnings.inc SET NAMES utf8; drop table test.`アアア`,test.`アアア$ex`; # # Test referencing old/new values of column names in utf8 # SET NAMES utf8; eval replace into mysql.ndb_replication values ("test", "アアア", $SLAVE_SERVER_ID, 7, NULL), ("test", "アアア", $MASTER_SERVER_ID, 7, "NDB\$EPOCH_TRANS()"); create table test.`アアア$ex` (ndb$server_id int unsigned, ndb$master_server_id int unsigned, ndb$master_epoch bigint unsigned, ndb$count int unsigned, `キキキ$old` varchar(2000) charset utf8, `キキキ$new` varchar(2000) charset utf8, `カカカ` int not null, ndb$op_type enum('write_row','update_row', 'delete_row') not null, ndb$cft_cause enum('row_does_not_exist','row_already_exists','data_in_conflict','trans_in_conflict') not null, ndb$orig_transid bigint unsigned not null, primary key(ndb$server_id, ndb$master_server_id, ndb$master_epoch, ndb$count)) engine=ndb; create table test.`アアア` ( `カカカ` int primary key, `キキキ` varchar(2000) charset utf8) engine=ndb; SET NAMES latin1; --let $pattern=%suspicious % column op_type % --let $limit=1 --source suite/ndb_rpl/t/show_mysqld_warnings.inc --connection slave flush logs; --sync_slave_with_master master # Cleanup --connection master drop table mysql.ndb_replication; drop table test.t1$EX, test.t1, test.t2$ex, test.t2; SET NAMES utf8; drop table test.`アアア`, test.`アアア$ex`; SET NAMES latin1; --sync_slave_with_master slave --connection slave flush logs; --sync_slave_with_master master stop slave; reset slave; #change master to master_host=''; --source include/rpl_end.inc
Save File
Cancel