File: rpl_relay_log_recovery_positions.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 (107 lines) | stat: -rw-r--r-- 4,415 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
#
# Test case for BUG#74089 scenario
#
--source include/force_restart.inc
--source include/have_binlog_format_statement.inc
--source include/master-slave.inc
--source include/rpl_connection_slave.inc

# Test starts here
--source include/rpl_reset.inc
--source include/rpl_connection_master.inc
--let $prefix= `SELECT UUID()`
--let $slave_error_log= $MYSQLTEST_VARDIR/tmp/$prefix.err

CREATE TABLE t1 (c1 INT);

--source include/sync_slave_sql_with_master.inc
CALL mtr.add_suppression("Recovery from source pos");

# stop the slave applier thread
--source include/stop_slave_sql.inc

--let $relay_log= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)

--source include/rpl_connection_master.inc

INSERT INTO t1 VALUES (1);

--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)

# make sure that the slave copies everything, but does not apply
# this last insert statement
--source include/sync_slave_io_with_master.inc

# Verify that the positions are the ones we expect at this
# point in time (read all the binary log, applied just the
# create table).

--let $begin_of_insert_trx_pos_in_rl= query_get_value(SHOW RELAYLOG EVENTS in '$relay_log', Pos, 8)
--let $create_tbl_stmt_trx_pos_in_bl= query_get_value(SHOW RELAYLOG EVENTS in '$relay_log', End_log_pos, 7)
--let $end_of_insert_trx_log_pos_in_rl= query_get_value(SHOW RELAYLOG EVENTS in '$relay_log', End_log_pos, 11)

--let $exec_master_log_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
--let $read_master_log_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1)
--let $relay_log_pos= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)

--let $assert_cond= $begin_of_insert_trx_pos_in_rl = $relay_log_pos
--let $assert_text= "Relay_log_pos points at the beginning of the INSERT trx."
--source include/assert.inc

--let $assert_cond= $create_tbl_stmt_trx_pos_in_bl = $exec_master_log_pos
--let $assert_text= "Exec_master_log_pos points at the CREATE TABLE statement."
--source include/assert.inc

--let $assert_cond= $end_of_insert_trx_log_pos_in_rl = $read_master_log_pos
--let $assert_text= "Read_master_log_pos points at the end of the INSERT trx."
--source include/assert.inc

#
# Restart the server with relay-log-recovery set - this will reset the positions
--let $rpl_server_parameters= --relay-log-recovery=1 --skip-replica-start --log_error=$slave_error_log --no-console
--let $rpl_omit_print_server_parameters= 1
--echo Omitting server parameters, since there is a path in one of them.
--source include/rpl_restart_server.inc

--let $exec_master_log_pos_restart= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
--let $read_master_log_pos_restart= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1)
--let $relay_log_pos_restart= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)

# Assert that the entry in the log contains the old relay log positions as well
--let $assert_text= Assert that the expected entry is in the error log
--let $assert_file= $slave_error_log
--let $assert_select= Recovery from source pos $exec_master_log_pos and file $binlog_file for channel ''. Previous relay log pos and relay log file had been set to $relay_log_pos, .*$relay_log respectively.
--let $assert_count= 1
--source include/assert_grep.inc

--let $assert_cond=$relay_log_pos_restart = 4
--let $assert_text= "Relay_log_pos points at the beginning of the new relay log file now."
--source include/assert.inc

--let $assert_cond= $read_master_log_pos_restart = $create_tbl_stmt_trx_pos_in_bl
--let $assert_text= "Read_master_log_pos after restart points at the CREATE TABLE position."
--source include/assert.inc

#
# Show that even though the positions have changed, the
# relay logs have not yet been purged. Lets assume that
# the master is crashed and thus the slave cannot connect
# to it. This means that we could try to apply the existing
# relay logs (maybe they are indeed corrupt, maybe they are
# not).
#

--replace_result $relay_log_pos RELAY_LOG_POS $relay_log SLAVE_RELAY_LOG_FILE_NAME
--eval CHANGE REPLICATION SOURCE TO Relay_log_pos= $relay_log_pos, Relay_log_file='$relay_log'
--source include/start_slave_sql.inc
--let $wait_condition= SELECT COUNT(*)=1 FROM t1
--source include/wait_condition.inc

--source include/start_slave_io.inc
--source include/rpl_connection_master.inc

DROP TABLE t1;

--source include/sync_slave_sql_with_master.inc

--source include/rpl_end.inc