Debian Codegraph @

mysql-test/suite/ndb_rpl/t/ndb_rpl_batch.test

raw
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 #
6 # Simple test to check that replica_allow_batching has at least a /2 effect
7 # on round trips.
8 # Further testing could be added in the areas of
9 # - Correlation of batch size to data written
10 # - Slave batching and Blobs
11 # - Slave batching and hidden/autoinc keys
12 # - Batching within a multi-image event with
13 # replica_allow_batching=OFF
14 #
15
16 --connection master
17
18 use test;
19
20 --echo Create a couple of tables to defeat Binlog Injector's
21 --echo creation of multi-image events which can be batch-applied
22 --echo on the slave regardless of replica_allow_batching
23
24 create table t1 (pk int primary key, a varchar(8000))
25 engine=ndb character set latin1;
26 create table t2 (pk int primary key, a varchar(8000))
27 engine=ndb character set latin1;
28
29 --echo Insert some data which we can later delete
30 --echo This also serves to 'prime' the Slave, so that NdbApi
31 --echo access related to slave setup (last_replicated_epoch fetch etc)
32 --echo can be ignored.
33
34 insert into t1 values (1, repeat("I", 80)), (2, repeat("R", 80));
35
36 --sync_slave_with_master
37
38 --echo First pass with replica_allow_batching OFF
39 --connection slave
40 set global replica_allow_batching=OFF;
41 show variables like 'replica_allow_batching';
42 #show status like 'ndb_api%slave';
43 --source ndb_slave_exec_info_init.inc
44
45 --connection master
46
47 --echo Check out batching
48 --echo Transaction includes deletes + inserts, and
49 --echo two different tables, shouldn't be entirely batchable
50 --echo without replica_allow_batching
51
52 begin;
53 delete from t1;
54 insert into t1 values (3, repeat("I", 80)), (4, repeat("F", 80));
55 insert into t2 values (5, repeat("B", 90)), (6, repeat("E", 90));
56 commit;
57
58 --sync_slave_with_master
59 --connection slave
60
61 #show status like 'ndb_api%slave';
62
63 --disable_query_log
64 --disable_result_log
65 SELECT @start_exec_count:=@init_wait_exec_complete_count_slave;
66 SELECT @start_pk_op_count:=@init_pk_op_count_slave;
67 --enable_result_log
68 --enable_query_log
69
70 --source ndb_slave_exec_info_init.inc
71
72 --disable_query_log
73 --disable_result_log
74 SELECT @batching_off_execs:=@init_wait_exec_complete_count_slave - @start_exec_count AS 'Exec_count';
75 SELECT @batching_off_pk_ops:=@init_pk_op_count_slave - @start_pk_op_count AS 'Pk_op_count';
76 --enable_result_log
77 --enable_query_log
78
79 --connection master
80 delete from t1;
81 delete from t2;
82 insert into t1 values (1, repeat("I", 80)), (2, repeat("R", 80));
83
84 --sync_slave_with_master
85 --connection slave
86 --echo Second pass with replica_allow_batching ON
87 set global replica_allow_batching=ON;
88 show variables like 'replica_allow_batching';
89 #show status like 'ndb_api%slave';
90 --source ndb_slave_exec_info_init.inc
91
92 --connection master
93
94 --echo Check out batching
95 --echo Transaction includes deletes + inserts, and
96 --echo two different tables, shouldn't be batchable
97 --echo without replica_allow_batching
98
99 begin;
100 delete from t1;
101 insert into t1 values (3, repeat("I", 80)), (4, repeat("F", 80));
102 insert into t2 values (5, repeat("B", 90)), (6, repeat("E", 90));
103 commit;
104
105 --sync_slave_with_master
106 --connection slave
107
108 #show status like 'ndb_api%slave';
109
110 --echo Determine slave activity in terms of PK ops and execute() calls
111 --disable_query_log
112 --disable_result_log
113 SELECT @start_exec_count:=@init_wait_exec_complete_count_slave;
114 SELECT @start_pk_op_count:=@init_pk_op_count_slave;
115 --enable_result_log
116 --enable_query_log
117
118 --source ndb_slave_exec_info_init.inc
119
120 --disable_query_log
121 --disable_result_log
122 SELECT @batching_on_execs:=@init_wait_exec_complete_count_slave - @start_exec_count AS 'Exec_count';
123 SELECT @batching_on_pk_ops:=@init_pk_op_count_slave - @start_pk_op_count AS 'Pk_op_count';
124 --enable_result_log
125 --enable_query_log
126
127 --echo Check that test compared like-for-like, and that replica_allow_batching
128 --echo came out ahead by a factor of at least 2.
129 SELECT @batching_on_pk_ops = @batching_off_pk_ops AS 'Fair contest';
130 SELECT @batching_off_pk_ops >=4 as 'Batching can improve matters';
131 SELECT @batching_on_execs * 2 < @batching_off_execs AS 'replica_allow_batching works';
132
133 --echo Cleanup
134 --connection master
135 drop table t2;
136 drop table t1;
137 --sync_slave_with_master
138 --connection master
139
140 --source include/rpl_end.inc