| 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 |
--echo |
| 6 |
--echo Assert bounds of ndb_replica_blob_write_batch_bytes |
| 7 |
--echo |
| 8 |
|
| 9 |
# Should be truncated to 0 |
| 10 |
set @@GLOBAL.ndb_replica_blob_write_batch_bytes = -1; |
| 11 |
show variables like 'ndb_replica_blob_write_batch_bytes'; |
| 12 |
|
| 13 |
# Should be truncated to max (2^30) |
| 14 |
set @@GLOBAL.ndb_replica_blob_write_batch_bytes = 2 * 1024 * 1024 * 1024 + 1; |
| 15 |
show variables like 'ndb_replica_blob_write_batch_bytes'; |
| 16 |
|
| 17 |
# Cannot be set as SESSION variable |
| 18 |
--error ER_GLOBAL_VARIABLE |
| 19 |
set @@SESSION.ndb_replica_blob_write_batch_bytes = 32768; |
| 20 |
|
| 21 |
set @@GLOBAL.ndb_replica_blob_write_batch_bytes = DEFAULT; |
| 22 |
show variables like 'ndb_replica_blob_write_batch_bytes'; |
| 23 |
|
| 24 |
--echo |
| 25 |
|
| 26 |
# This test illustrates the usage of replica specific blob batch write |
| 27 |
# byte size, that can be independently used from the source's binlog |
| 28 |
# applier. If set to a large value it can greatly reduce the |
| 29 |
# amount of execute() calls |
| 30 |
|
| 31 |
# Low batch write size, set to 512 bytes only |
| 32 |
|
| 33 |
--connection slave |
| 34 |
set global replica_allow_batching = ON; |
| 35 |
set ndb_blob_write_batch_bytes = DEFAULT; |
| 36 |
set ndb_blob_read_batch_bytes = DEFAULT; |
| 37 |
set @@GLOBAL.ndb_replica_blob_write_batch_bytes = 512; |
| 38 |
show global variables like 'ndb_replica_blob_write_batch_bytes'; |
| 39 |
|
| 40 |
--connection master |
| 41 |
set global ndb_log_update_as_write = ON; |
| 42 |
|
| 43 |
create table t1 (a int primary key, b blob) engine=ndb; |
| 44 |
create table t2 (a int primary key, b blob) engine=ndb; |
| 45 |
|
| 46 |
--sync_slave_with_master |
| 47 |
|
| 48 |
--connection slave |
| 49 |
--source ndb_slave_exec_info_init.inc |
| 50 |
|
| 51 |
--connection master |
| 52 |
--echo |
| 53 |
--echo Bulk insert (~1MB) and update with low batch size |
| 54 |
--echo |
| 55 |
|
| 56 |
--disable_query_log |
| 57 |
begin; |
| 58 |
insert into t1 values |
| 59 |
(1, repeat(x'62', 65024)), |
| 60 |
(2, repeat(x'62', 65024)), |
| 61 |
(3, repeat(x'62', 65024)), |
| 62 |
(4, repeat(x'62', 65024)), |
| 63 |
(5, repeat(x'62', 65024)), |
| 64 |
(6, repeat(x'62', 65024)), |
| 65 |
(7, repeat(x'62', 65024)), |
| 66 |
(8, repeat(x'62', 65024)); |
| 67 |
insert into t2 values |
| 68 |
(1, repeat(x'63', 65024)), |
| 69 |
(2, repeat(x'63', 65024)), |
| 70 |
(3, repeat(x'63', 65024)), |
| 71 |
(4, repeat(x'63', 65024)), |
| 72 |
(5, repeat(x'63', 65024)), |
| 73 |
(6, repeat(x'63', 65024)), |
| 74 |
(7, repeat(x'63', 65024)), |
| 75 |
(8, repeat(x'63', 65024)); |
| 76 |
update t1 set b=repeat(x'63', 65024) where a in (1,2,3,4,5,6,7,8); |
| 77 |
update t2 set b=repeat(x'62', 65024) where a in (1,2,3,4,5,6,7,8); |
| 78 |
commit; |
| 79 |
|
| 80 |
--sync_slave_with_master |
| 81 |
|
| 82 |
--connection slave |
| 83 |
--disable_query_log |
| 84 |
SET @start_exec_count = @init_wait_exec_complete_count_slave; |
| 85 |
SET @start_pk_op_count = @init_pk_op_count_slave; |
| 86 |
--source ndb_slave_exec_info_init.inc |
| 87 |
--disable_query_log |
| 88 |
SET @low_batch_exec_count = @init_wait_exec_complete_count_slave - @start_exec_count; |
| 89 |
SET @low_batch_pk_op_count = @init_pk_op_count_slave - @start_pk_op_count; |
| 90 |
|
| 91 |
--connection master |
| 92 |
delete from t1; |
| 93 |
delete from t2; |
| 94 |
|
| 95 |
--sync_slave_with_master |
| 96 |
|
| 97 |
--connection slave |
| 98 |
--enable_query_log |
| 99 |
# Now increase replica's blob batch size only (4MB) and reset counters |
| 100 |
set @@GLOBAL.ndb_replica_blob_write_batch_bytes = 4 * 1024 * 1024; |
| 101 |
show global variables like 'ndb_replica_blob_write_batch_bytes'; |
| 102 |
--source ndb_slave_exec_info_init.inc |
| 103 |
|
| 104 |
--connection master |
| 105 |
--echo |
| 106 |
--echo Bulk insert (~1MB) and update with higher batch size |
| 107 |
--echo |
| 108 |
|
| 109 |
--disable_query_log |
| 110 |
begin; |
| 111 |
insert into t1 values |
| 112 |
(1, repeat(x'62', 65024)), |
| 113 |
(2, repeat(x'62', 65024)), |
| 114 |
(3, repeat(x'62', 65024)), |
| 115 |
(4, repeat(x'62', 65024)), |
| 116 |
(5, repeat(x'62', 65024)), |
| 117 |
(6, repeat(x'62', 65024)), |
| 118 |
(7, repeat(x'62', 65024)), |
| 119 |
(8, repeat(x'62', 65024)); |
| 120 |
insert into t2 values |
| 121 |
(1, repeat(x'63', 65024)), |
| 122 |
(2, repeat(x'63', 65024)), |
| 123 |
(3, repeat(x'63', 65024)), |
| 124 |
(4, repeat(x'63', 65024)), |
| 125 |
(5, repeat(x'63', 65024)), |
| 126 |
(6, repeat(x'63', 65024)), |
| 127 |
(7, repeat(x'63', 65024)), |
| 128 |
(8, repeat(x'63', 65024)); |
| 129 |
update t1 set b=repeat(x'63', 65024) where a in (1,2,3,4,5,6,7,8); |
| 130 |
update t2 set b=repeat(x'62', 65024) where a in (1,2,3,4,5,6,7,8); |
| 131 |
commit; |
| 132 |
|
| 133 |
--sync_slave_with_master |
| 134 |
|
| 135 |
--connection slave |
| 136 |
SET @start_exec_count = @init_wait_exec_complete_count_slave; |
| 137 |
SET @start_pk_op_count = @init_pk_op_count_slave; |
| 138 |
--source ndb_slave_exec_info_init.inc |
| 139 |
--disable_query_log |
| 140 |
SET @high_batch_exec_count = @init_wait_exec_complete_count_slave - @start_exec_count; |
| 141 |
SET @high_batch_pk_op_count = @init_pk_op_count_slave - @start_pk_op_count; |
| 142 |
|
| 143 |
--enable_query_log |
| 144 |
--echo Observe that the number of execute() decrease significantly while PK ops are maintained. |
| 145 |
--echo Execute() calls should have decreased by, at least, a factor of 8. |
| 146 |
SELECT @high_batch_exec_count < @low_batch_exec_count AS 'Large batch size execute calls are less'; |
| 147 |
SELECT @high_batch_pk_op_count = @low_batch_pk_op_count AS 'Same PK ops'; |
| 148 |
SELECT @low_batch_exec_count / @high_batch_exec_count >= 8 AS 'Factor of at least >= 8 for large batch'; |
| 149 |
|
| 150 |
--echo Cleanup |
| 151 |
--connection master |
| 152 |
set @@GLOBAL.ndb_log_update_as_write = ON; |
| 153 |
drop table t1; |
| 154 |
drop table t2; |
| 155 |
|
| 156 |
--connection slave |
| 157 |
set @@GLOBAL.ndb_replica_blob_write_batch_bytes = DEFAULT; |
| 158 |
set @@GLOBAL.replica_allow_batching = ON; |
| 159 |
|
| 160 |
--source include/rpl_end.inc |