File: rpl_invalid_position_with_gtid_only.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 (176 lines) | stat: -rw-r--r-- 6,568 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# ==== Purpose ====
#
# This test validates that when positions are invalid they are reported as such
#
# ==== Requirements ====
#
# R1. Verify that  positions as shown as invalid in `SHOW REPLICA STATUS`
#
# ==== Implementation ====
#
# 1. Setup:
#     Start the replica channel with GTID_ONLY=1
#     Add some info in the source and replicate it
#     Restart the replica but don't start replication
# 2 Assert all invalid positions in SHOW REPLICA STATUS are shown as such
# 3 Start the replica IO thread.
#   Check receiver positions are now valid
# 4 Start the replica SQL thread and replicate a transaction
#   Check applier positions in relation to the source are now valid
# 5 Check the starting SQL thread message reports invalid positions
# 6 Cleanup
#
# ==== References ====
#
# WL#7491: GTID-based replication applier recovery and positioning
#

--source include/have_binlog_format_row.inc
--let $rpl_skip_start_slave= 1
--source include/master-slave.inc

--echo #
--echo # 1. Setup:
--echo #     Start the replica channel with GTID_ONLY=1
--echo #     Add some data in the source and replicate it
--echo #     Restart the replica but don't start replication

--source include/rpl_connection_slave.inc

# Reduce this to a minimum
--let $replica_checkpoint_period_value = `SELECT @@global.replica_checkpoint_period`
SET @@GLOBAL.replica_checkpoint_period= 1;

CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 1, GTID_ONLY = 1;

--source include/start_slave.inc

--let $assert_text= 'GTID_ONLY is enabled'
--let $assert_cond= [SELECT GTID_ONLY FROM performance_schema.replication_connection_configuration, GTID_ONLY, 1] = 1
--source include/assert.inc

--source include/rpl_connection_master.inc

CREATE TABLE t(s INT);
INSERT INTO t VALUES(1);

--source include/sync_slave_sql_with_master.inc

--let $source_log_file_orig=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1)
--let $source_log_pos_orig=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1)

--let $rpl_server_number = 2
--let $rpl_server_parameters = --skip_slave_start
--let $explicit_default_wait_counter = 15000
--source include/rpl_restart_server.inc

--echo #
--echo # 2 Assert all invalid positions in SHOW REPLICA STATUS are shown as such

--let $source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1)
--let $assert_cond= [ SELECT "$source_log_file" = "INVALID" ]
--let $assert_text= The source log file name is invalid
--source include/assert.inc

--let $source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1)
--let $assert_cond= [ SELECT "$source_log_pos" = "0" ]
--let $assert_text= The source log file position is 0
--source include/assert.inc

--let $applier_source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Source_Log_File, 1)
--let $assert_cond= [ SELECT "$applier_source_log_file" = "INVALID" ]
--let $assert_text= The source log file name in the applier is invalid
--source include/assert.inc

--let $applier_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Exec_Source_Log_Pos, 1)
--let $assert_cond= [ SELECT "$applier_source_log_pos" = "0" ]
--let $assert_text= The source log file position in the applier is 0
--source include/assert.inc

--echo #
--echo # 3 Start the replica IO thread.
--echo #   Check receiver positions are now valid

--source include/start_slave_io.inc

--let $show_statement= SHOW REPLICA STATUS FOR CHANNEL ''
--let $field= Source_Log_File
--let $condition= != 'INVALID'
--source include/wait_show_condition.inc

--let $source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1)
--let $assert_cond= [ SELECT "$source_log_file" = "$source_log_file_orig" ]
--let $assert_text= The source log file name is back to the previous value
--source include/assert.inc

--let $source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1)
--let $assert_cond= [ SELECT "$source_log_pos" = "$source_log_pos_orig" ]
--let $assert_text= The source log file is back to the previous position
--source include/assert.inc

--echo #
--echo # 4 Start the replica SQL thread and replicate a transaction
--echo #   Check applier positions in relation to the source are now valid

# Reduce this to a minimum again after the restart
SET @@GLOBAL.replica_checkpoint_period= 1;

--source include/start_slave_sql.inc

--source include/rpl_connection_master.inc

# In truth a simple rotate or already skipped transaction in the relay log
# turns the positions valid again.
INSERT INTO t VALUES(2);

--source include/sync_slave_sql_with_master.inc

--source include/rpl_connection_master.inc

--let $log_file_on_source=query_get_value(SHOW MASTER STATUS, File, 1)
--let $log_pos_on_source=query_get_value(SHOW MASTER STATUS, Position, 1)

--source include/rpl_connection_slave.inc

# Relay log is only updated on checkpoint points
--let $show_statement= SHOW REPLICA STATUS FOR CHANNEL ''
--let $field= Relay_Source_Log_File
--let $condition= != 'INVALID'
--source include/wait_show_condition.inc

--let $applier_source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Source_Log_File, 1)
--let $assert_cond= [ SELECT "$applier_source_log_file" = "$log_file_on_source" ]
--let $assert_text= The source log file name for the applier is the one used on the source
--source include/assert.inc

--let $applier_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Exec_Source_Log_Pos, 1)
--let $assert_cond= [ SELECT "$applier_source_log_pos" = "$log_pos_on_source" ]
--let $assert_text= The source log file position in the applier is last applied on the source
--source include/assert.inc

--echo #
--echo # 5 Check the starting SQL thread message reports invalid positions

--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
--let $assert_select= Replica SQL thread for channel '' initialized, starting replication in log 'INVALID' at position 0, relay log *
--let $assert_count= 1
--let $assert_text= The SQL thread start will report the information in relation to the source as invalid
--source include/assert_grep.inc

--echo #
--echo # 6 Cleanup

--replace_result $replica_checkpoint_period_value REPLICA_CHECKPOINT_PERIOD
--eval SET @@GLOBAL.replica_checkpoint_period= $replica_checkpoint_period_value

--source include/stop_slave.inc

CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 0, GTID_ONLY = 0;

--source include/start_slave.inc

--source include/rpl_connection_master.inc

DROP TABLE t;

--source include/rpl_end.inc