| 1 |
--source include/have_ndb.inc |
| 2 |
--source include/have_binlog_format_mixed_or_row.inc |
| 3 |
--source suite/ndb_rpl/ndb_master-slave.inc |
| 4 |
|
| 5 |
# WL#15070 Configure replica specific batch_size |
| 6 |
|
| 7 |
--echo |
| 8 |
--echo Assert bounds of ndb_replica_batch_size |
| 9 |
--echo |
| 10 |
|
| 11 |
# Should be truncated to 0 |
| 12 |
set @@GLOBAL.ndb_replica_batch_size = -1; |
| 13 |
show variables like 'ndb_replica_batch_size'; |
| 14 |
|
| 15 |
# Should be truncated to 2147483648 (2^30) |
| 16 |
set @@GLOBAL.ndb_replica_batch_size = 2147483649; |
| 17 |
show variables like 'ndb_replica_batch_size'; |
| 18 |
|
| 19 |
# Cannot be set as SESSION variable |
| 20 |
--error ER_GLOBAL_VARIABLE |
| 21 |
set @@SESSION.ndb_replica_batch_size = 32768; |
| 22 |
|
| 23 |
set @@GLOBAL.ndb_replica_batch_size = DEFAULT; |
| 24 |
show variables like 'ndb_replica_batch_size'; |
| 25 |
|
| 26 |
--echo |
| 27 |
|
| 28 |
# This test asserts that replica specific batch_size, when applied to |
| 29 |
# replica's binlog injector's thread, improves (reduces) the amount of |
| 30 |
# round trips required. |
| 31 |
# It compares the default of ndb_batch_size, 32kB, with the |
| 32 |
# replica_ndb_batch_size default of 2MB producing improvements. |
| 33 |
|
| 34 |
--connection slave |
| 35 |
set @@GLOBAL.ndb_replica_batch_size = 32768; |
| 36 |
set global replica_allow_batching=ON; |
| 37 |
|
| 38 |
--connection master |
| 39 |
|
| 40 |
create table t1 (a int primary key, b varchar(7000)) |
| 41 |
engine=ndb; |
| 42 |
create table t2 (a int primary key, b varchar(7000)) |
| 43 |
engine=ndb; |
| 44 |
create table t3 (a int primary key, b varchar(7000)) |
| 45 |
engine=ndb; |
| 46 |
create table t4 (a int primary key, b varchar(7000)) |
| 47 |
engine=ndb; |
| 48 |
|
| 49 |
--echo |
| 50 |
--echo Record the replica's NDB API current wait count. |
| 51 |
--echo Insert some wide data into the tables, synchronize |
| 52 |
--echo and record how many more times NDB API waited for |
| 53 |
--echo and primary key operations. |
| 54 |
--echo |
| 55 |
|
| 56 |
--connection slave |
| 57 |
--source ndb_slave_exec_info_init.inc |
| 58 |
|
| 59 |
--connection master |
| 60 |
|
| 61 |
begin; |
| 62 |
insert into t1 values (1, repeat("B", 7000)); |
| 63 |
insert into t2 values (2, repeat("A", 7000)); |
| 64 |
insert into t2 values (3, repeat("T", 7000)); |
| 65 |
insert into t3 values (4, repeat("C", 7000)); |
| 66 |
insert into t4 values (5, repeat("H", 7000)); |
| 67 |
insert into t1 values (6, repeat("B", 7000)); |
| 68 |
insert into t2 values (7, repeat("A", 7000)); |
| 69 |
insert into t2 values (8, repeat("T", 7000)); |
| 70 |
insert into t3 values (9, repeat("C", 7000)); |
| 71 |
insert into t4 values (0, repeat("H", 7000)); |
| 72 |
update t1 set b = repeat('S', 7000); |
| 73 |
update t2 set b = repeat('I', 7000); |
| 74 |
update t3 set b = repeat('Z', 7000); |
| 75 |
update t4 set b = repeat('E', 7000); |
| 76 |
delete from t1 where a = 1; |
| 77 |
delete from t4 where a in (5,0); |
| 78 |
commit; |
| 79 |
|
| 80 |
--sync_slave_with_master |
| 81 |
|
| 82 |
--connection slave |
| 83 |
|
| 84 |
--echo |
| 85 |
--echo Record replica's API execute() calls and PK ops, and cleanup |
| 86 |
--echo |
| 87 |
|
| 88 |
--disable_query_log |
| 89 |
SET @start_exec_count = @init_wait_exec_complete_count_slave; |
| 90 |
SET @start_pk_op_count = @init_pk_op_count_slave; |
| 91 |
--enable_query_log |
| 92 |
|
| 93 |
--source ndb_slave_exec_info_init.inc |
| 94 |
|
| 95 |
--disable_query_log |
| 96 |
SET @low_batch_exec_count = @init_wait_exec_complete_count_slave - @start_exec_count; |
| 97 |
SET @low_batch_pk_op_count = @init_pk_op_count_slave - @start_pk_op_count; |
| 98 |
--enable_query_log |
| 99 |
|
| 100 |
--connection master |
| 101 |
delete from t1; |
| 102 |
delete from t2; |
| 103 |
delete from t3; |
| 104 |
delete from t4; |
| 105 |
--sync_slave_with_master |
| 106 |
|
| 107 |
--echo |
| 108 |
--echo Increase replica's batch size for the binlog injector by 4-fold |
| 109 |
--echo and perform the same operations. |
| 110 |
--echo |
| 111 |
|
| 112 |
--connection slave |
| 113 |
# Should be 2MB |
| 114 |
set @@GLOBAL.ndb_replica_batch_size = DEFAULT; |
| 115 |
--source ndb_slave_exec_info_init.inc |
| 116 |
|
| 117 |
--connection master |
| 118 |
|
| 119 |
begin; |
| 120 |
insert into t1 values (1, repeat("B", 7000)); |
| 121 |
insert into t2 values (2, repeat("A", 7000)); |
| 122 |
insert into t2 values (3, repeat("T", 7000)); |
| 123 |
insert into t3 values (4, repeat("C", 7000)); |
| 124 |
insert into t4 values (5, repeat("H", 7000)); |
| 125 |
insert into t1 values (6, repeat("B", 7000)); |
| 126 |
insert into t2 values (7, repeat("A", 7000)); |
| 127 |
insert into t2 values (8, repeat("T", 7000)); |
| 128 |
insert into t3 values (9, repeat("C", 7000)); |
| 129 |
insert into t4 values (0, repeat("H", 7000)); |
| 130 |
update t1 set b = repeat('S', 7000); |
| 131 |
update t2 set b = repeat('I', 7000); |
| 132 |
update t3 set b = repeat('Z', 7000); |
| 133 |
update t4 set b = repeat('E', 7000); |
| 134 |
delete from t1 where a = 1; |
| 135 |
delete from t4 where a in (5,0); |
| 136 |
commit; |
| 137 |
|
| 138 |
--sync_slave_with_master |
| 139 |
--connection slave |
| 140 |
|
| 141 |
--disable_query_log |
| 142 |
SET @large_batch_start_exec_count = @init_wait_exec_complete_count_slave; |
| 143 |
SET @large_batch_start_pk_op_count = @init_pk_op_count_slave; |
| 144 |
--enable_query_log |
| 145 |
|
| 146 |
--source ndb_slave_exec_info_init.inc |
| 147 |
|
| 148 |
--disable_query_log |
| 149 |
SET @large_batch_exec_count = @init_wait_exec_complete_count_slave - @large_batch_start_exec_count; |
| 150 |
SET @large_batch_pk_op_count = @init_pk_op_count_slave - @large_batch_start_pk_op_count; |
| 151 |
--enable_query_log |
| 152 |
|
| 153 |
--echo Observe that the number of execute() decrease significantly as well as the PK ops. |
| 154 |
--echo Execute() calls should have decreased by, at least, a factor of 4. |
| 155 |
--echo PK ops should have decreased by, at least, a factor of 2. |
| 156 |
SELECT @large_batch_exec_count < @low_batch_exec_count AS 'Large batch size execute calls are less'; |
| 157 |
SELECT @large_batch_pk_op_count < @low_batch_pk_op_count AS 'Large batch size PK ops are less'; |
| 158 |
SELECT @low_batch_exec_count / @large_batch_exec_count >= 4 AS 'Factor of >=4 for large batch execute calls'; |
| 159 |
SELECT @low_batch_pk_op_count / @large_batch_pk_op_count > 1 AS 'Factor of > 1 for large batch PK op'; |
| 160 |
|
| 161 |
--echo Cleanup |
| 162 |
--connection master |
| 163 |
set global ndb_replica_batch_size = DEFAULT; |
| 164 |
set global replica_allow_batching = DEFAULT; |
| 165 |
drop table t1; |
| 166 |
drop table t2; |
| 167 |
drop table t3; |
| 168 |
drop table t4; |
| 169 |
--sync_slave_with_master |
| 170 |
|
| 171 |
--connection slave |
| 172 |
set global ndb_replica_batch_size = DEFAULT; |
| 173 |
set global replica_allow_batching = DEFAULT; |
| 174 |
|
| 175 |
--source include/rpl_end.inc |