1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
--source include/have_rocksdb.inc
--source include/master-slave.inc
--source include/have_debug.inc
connection master;
SET @prior_rocksdb_perf_context_level = @@rocksdb_perf_context_level;
SET GLOBAL rocksdb_perf_context_level=3;
SET GLOBAL enable_blind_replace=ON;
# Create and insert some rows in a table
create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;
# Create table which has a trigger only in slave
create table t2(c1 int,c2 int, primary key (c1)) engine=rocksdb;
insert into t2 values(1,1),(2,2),(3,3);
select * from t2;
# Create table which has a secondary key only in slave
create table t3(c1 int,c2 int, primary key (c1)) engine=rocksdb;
insert into t3 values(1,1),(2,2),(3,3);
select * from t3;
sync_slave_with_master;
# Enable blind replace in both slave and master
connection slave;
SET GLOBAL enable_blind_replace=ON;
create trigger trg before insert on t2 for each row set @a:=1;
alter table t3 add constraint slave_unique_key unique (c2);
connection master;
sync_slave_with_master;
--echo connect slave
select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
# Case 1 - 'replace into' on a table with no triggers or secondary keys. Blind replace optimization should kick in both in master and slave
--echo Case 1
connection master;
--echo connect master
select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
replace into t1 values(2,22);
replace into t1 values(3,33);
select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
select * from t1;
sync_slave_with_master;
--echo connect slave
select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
select * from t1;
select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
# Case 2 - Multiple replaces in a single statement. blind replace optimization should kick in
connection master;
--echo Case 2
--echo connect master
select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(2,44),(3,55);
select case when variable_value-@d > 2 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
select * from t1;
sync_slave_with_master;
--echo connect slave
select case when variable_value-@d > 2 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
select * from t1;
select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
# Case 3 - A regular update. This is not a blind replace
--echo Case 3
connection master;
--echo connect master
update t1 set c2=66 where c1=3;
select * from t1;
sync_slave_with_master;
--echo connect slave
select * from t1;
select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
# Case 4 - Slave has trigger on its table. No triggers on the table in master.
# Blind replace optimization should kick in on master.
# Slave should convert this statement into a regular update
--echo Case 4
connection master;
--echo connect master
select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t2 values(1,111);
replace into t2 values(2,222);
replace into t2 values(3,333);
select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
select * from t2;
sync_slave_with_master;
--echo connect slave
select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
select * from t2;
select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
# Case 5 - Slave has secondary keys on the table. No secondary keys on the table in master
# Blind replace optimization should kick in on master.
# Slave should convert this statement into a regular delete_insert
--echo Case 5
connection master;
--echo connect master
select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t3 values(1,1111);
replace into t3 values(2,2222);
replace into t3 values(3,3333);
select * from t3;
select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
sync_slave_with_master;
--echo connect slave
select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
select * from t3;
select * from t3 use index (slave_unique_key);
# Case 6 - Just to verify all binlog events.
# blind replace will generate a write_rows event.
# Or else, it will be a update_rows event or a delete_rows_write_rows event
--echo Case 6
connection master;
--source include/show_binlog_events.inc
connection slave;
--source include/show_binlog_events.inc
# Cleanup
connection master;
drop table t1;
drop table t2;
drop table t3;
SET GLOBAL rocksdb_perf_context_level = @prior_rocksdb_perf_context_level;
SET GLOBAL enable_blind_replace=DEFAULT;
connection slave;
SET GLOBAL enable_blind_replace=DEFAULT;
--source include/rpl_end.inc
|