File: rpl_mts_stop_slave_report_pos.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (134 lines) | stat: -rw-r--r-- 5,518 bytes parent folder | download
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
# ==== Purpose ====
#
# Verify that the positions that are reported by the applier thread during
# STOP SLAVE are the same as that of the most recent checkpoint in case of
# Multi Threaded Slave.
#
# ==== Implementation ====
#
# 1) Create two databases and do some DML operations on these databases.
# 2) Sync the slave applier with master to insure that a checkpoint is done.
# 3) Set bigger values for replica_checkpoint_period/group so that no further
#    checkpoints are done on slave server.
# 4) Execute few more DMLS on master and wait till they are applied on slave.
# 5) This is to prove that applier thread has few more committed transactions
#    after the checkpoint done at step 2.
# 6) Execute STOP SLAVE command.
# 7) Assert that the positions that are reported in error log are as per the
#    latest checkpoint.
#
# ==== References ====
#
# Bug#27300658: IN MTS SQL THREAD EXITING AND INITIALIZING
# MESSAGE WITH DIFFERENT POSITION

# This test case is binary log format agnostic
--source include/have_binlog_format_row.inc
--source include/have_debug.inc
--source include/only_mts_replica_parallel_workers.inc
# do not execute when binlog compression is on as the debug
# point below is not activated
--source include/not_binlog_transaction_compression_on.inc
--source include/master-slave.inc

# Do some DMLs on master and sync with slave to make sure that one checkpoint
# is done.
CREATE DATABASE db1;
CREATE DATABASE db2;
CREATE TABLE db1.t1 ( id INT(11) PRIMARY KEY ) ENGINE=INNODB;
CREATE TABLE db2.t1 ( id INT(11) PRIMARY KEY ) ENGINE=INNODB;
INSERT INTO db1.t1 VALUES (40);
INSERT INTO db2.t1 VALUES (40);
--source include/sync_slave_sql_with_master.inc

# Save the global variables that are being modified. Set bigger values for
# replica_checkpoint_group/period so that no further checkpoints are done
# automatically.
SET @save_debug = @@GLOBAL.debug;
SET @save_replica_checkpoint_group= @@GLOBAL.replica_checkpoint_group;
SET @save_replica_checkpoint_period= @@GLOBAL.replica_checkpoint_period;
SET GLOBAL replica_checkpoint_group=512;
SET GLOBAL replica_checkpoint_period=3000000;

# Do some DMLs on master.
--source include/rpl_connection_master.inc
--let $i=30
while ($i)
{
  --eval insert into db1.t1 values ($i)
  --eval insert into db2.t1 values ($i)
  dec $i;
}
--source include/sync_slave_io_with_master.inc

# Wait till all the transactions are applied on slave. This will ensure that
# at the time of STOP SLAVE few more committited transactions are present
# above the recent LWM.
--source include/rpl_connection_slave.inc
--let $table=db1.t1
--let $count=31
--source include/wait_until_rows_count.inc

--let $table=db2.t1
--let $count=31
--source include/wait_until_rows_count.inc
--source include/stop_slave_io.inc

# Wait for coordinator to populate worker's queues.
--let $show_statement= SHOW PROCESSLIST
--let $field= State
--let $condition= = 'Replica has read all relay log; waiting for more updates'
--source include/wait_show_condition.inc


# Initiate one more DML on master. While the DML is being processed by slave
# applier it will receive a STOP SLAVE due to debug simulation. Applier will
# execute gracefully after completing the current group in progress and print
# appropriate exit positions.
--source include/rpl_connection_master.inc
BEGIN;
INSERT INTO db1.t1 VALUES (50);
COMMIT;

--source include/rpl_connection_slave.inc
# Debug simulation which will ensure that SLAVE STOPS as a regular exit
# without an error. This ensures we have the same scenario as that of the bug
# report.
SET global debug="+d,simulate_stop_when_mta_in_group";
--source include/start_slave_io.inc

--source include/wait_for_slave_sql_to_stop.inc
--let $exec_master_log_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
--let $exec_master_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)

# Assert that the positions that are reported by the applier thread during
# STOP SLAVE are the same as that of the most recent checkpoint in case of
# Multi Threaded Slave.
--let $assert_text= Assert that the expected entry is in the error log during STOP SLAVE
--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
--let $assert_only_after = Coordinator thread of multi-threaded replica is being stopped in the middle of assigning a group of events
--let $assert_select= Replica SQL thread for channel '' exiting, replication stopped in log '$exec_master_log_file' at position $exec_master_log_pos
--let $assert_count= 1
--source include/assert_grep.inc

SET GLOBAL debug=@save_debug;
SET @@GLOBAL.replica_checkpoint_group= @save_replica_checkpoint_group;
set @@GLOBAL.replica_checkpoint_period= @save_replica_checkpoint_period;
--source include/start_slave.inc

# Assert that the positions that are reported by the applier thread during
# START SLAVE are the same as the positions reported during STOP SLAVE.
--let $assert_text= Assert that the expected entry is in the error log during START SLAVE
--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
--let $assert_only_after = Replica SQL thread exiting, replication stopped in log
--let $assert_select= Replica SQL thread for channel '' initialized, starting replication in log '$exec_master_log_file' at position $exec_master_log_pos
--let $assert_count= 1
--source include/assert_grep.inc

--source include/rpl_connection_master.inc
--source include/sync_slave_sql_with_master.inc

--source include/rpl_connection_master.inc
DROP DATABASE db1;
DROP DATABASE db2;
--source include/rpl_end.inc