Debian Codegraph @

mysql-test/suite/rpl/t/rpl_parallel_seconds_behind_master.test

raw
1 #
2 # Testing of Seconds_Behind_Master (SBM) to behave as the following
3 # SBM changes discretely per some number of processed group of events,
4 # e.g transactions.
5 # The number is either @@global.replica_checkpoint_group or less if
6 # @@global.replica_checkpoint_period timer elapses first.
7 # The value updates *after* the last group commit is executed.
8 # Resetting to zero behavior when Slave goes to read events is
9 # preserved.
10 #
11 # Test times out in Valgrind
12 -- source include/not_valgrind.inc
13 -- source include/master-slave.inc
14 -- source include/have_debug.inc
15
16 # make the test only run once (STMT is actually needed because we rely
17 # on SHOW PROCESS LIST output in some of the tests)
18 -- source include/have_binlog_format_statement.inc
19
20
21 # restart slave in MTS mode
22 connection slave;
23 source include/stop_slave.inc;
24 set @save.replica_parallel_workers= @@global.replica_parallel_workers;
25 set @@global.replica_parallel_workers= 4;
26 set @save.replica_checkpoint_period= @@global.replica_checkpoint_period;
27 set @@global.replica_checkpoint_period= 500; # 0.5 sec
28 # to avoid warnings
29 set @save.replica_transaction_retries= @@global.replica_transaction_retries;
30
31 #
32 # Idea of demonstration.
33 #
34 # Two transactions on the same db are generated for MTS. The first has some
35 # natural delay, and the 2nd will be locked out of its data.
36 # While the first is being processed Coordinator empties the relay-log
37 # to enter waiting for more events.
38 # It does so being awakened @@global.replica_checkpoint_period-ically
39 # to check out if some groups of events have been done to update SBM (demo 1).
40 #
41 # Resetting of SBM is a possibility whenever Coordinator
42 # notices no more groups left neither to read nor to process (demo 2).
43 #
44 --source include/start_slave.inc
45
46 connection master;
47
48 --disable_query_log
49 # todo: sleep() is deterministic!!!
50 call mtr.add_suppression('.*Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.*');
51 --enable_query_log
52
53 create table t1 (f1 int) engine=innodb;
54 create table t2 (f1 int) engine=innodb;
55 --source include/sync_slave_sql_with_master.inc
56
57 --source include/stop_slave_sql.inc
58 # 1st transaction that will be used to compute SBM.
59 # It will hang $idle time at least in processing to get min estimate for SBM
60 connection master;
61 let $idle= 3;
62
63 begin;
64 eval insert into t1 values (sleep($idle) + 1);
65 commit;
66
67 # 2nd transaction to block Coordinator from resetting SBM
68 begin;
69 insert into t2 values (1);
70 commit;
71
72 #
73 # all events are in relay-log
74 #
75 source include/sync_slave_io_with_master.inc;
76
77 connection slave1;
78 lock table t2 write; # to block 2nd trans
79
80 connection slave;
81 --source include/start_slave_sql.inc
82 let $count= 1;
83 let $table= t1;
84 source include/wait_until_rows_count.inc;
85
86 --echo First transaction is done, now get Seconds_Behind_Master after it...
87
88 #
89 # demo 1:
90 # So now 1st is over, and it SBM must have gain at least $idle seconds.
91 #
92 let $slave_param= Seconds_Behind_Master;
93 let $slave_param_comparison= >=;
94 let $slave_param_value= $idle;
95 source include/wait_for_slave_param.inc;
96
97 --echo Seconds_Behind_Master after first transaction is as expected.
98
99 connection slave1;
100 unlock tables;
101
102 #
103 # demo 2: Resetting of SBM upon all groups have been processed and
104 # nothing left in relay-log.
105 #
106 connection slave;
107 let $slave_param= Seconds_Behind_Master;
108 let $slave_param_comparison= =;
109 let $slave_param_value= 0;
110 source include/wait_for_slave_param.inc;
111
112 ##
113 # cleanup
114 ##
115 connection master;
116 drop tables t1, t2;
117
118 --source include/sync_slave_sql_with_master.inc
119
120 set @@global.replica_checkpoint_period= @save.replica_checkpoint_period;
121 --disable_warnings
122 set @@global.replica_parallel_workers= @save.replica_parallel_workers;
123 --enable_warnings
124 set @@global.replica_transaction_retries= @save.replica_transaction_retries;
125
126 --source include/rpl_end.inc
127