File: rpl_change_master_relay_log_purge.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 (118 lines) | stat: -rw-r--r-- 4,607 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
# ==== Purpose ====
#
# This test script serves as the functionality testing for
# WL#6120- Change master without stopping slave.
#
# This test script does the following:

#  - If at least one of the receiver or applier threads is running, relay logs
#    should not be purged.
#  - If relay_log_file/relay_log_pos options are used, relay logs should
#    not be purged.
#  - If both receiver and applier threads are stopped and there is no use of
#    relay_log_file/relay_log_pos options, relay logs should be
#    purged.
#
#  ==== Related Worklog(s) And Bug(s)====
#
#  WL#6120- Change master without stopping Slave threads.
#

--source include/master-slave.inc
--source include/have_binlog_format_mixed.inc

FLUSH BINARY LOGS;

--source include/sync_slave_sql_with_master.inc

#save old values to restore after test in the cleanup section.
let $slave_heartbeat_timeout_before_test= query_get_value(select HEARTBEAT_INTERVAL from performance_schema.replication_connection_configuration, HEARTBEAT_INTERVAL, 1);
let $delay_before_test= query_get_value(SHOW SLAVE STATUS, SQL_Delay, 1);

--echo
--echo We now stop the IO thread and ensure that the relaylog files
--echo are not deleted on doing a change master with a running SQL thread.
--echo

# Note down the current relaylog file.
# CM stands for 'change master'.
let $relay_log_file_before_CM= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);

# Execute change master command with running SQL thread.
--source include/stop_slave_io.inc
CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD= 10;

# Note down the active relaylog after change master
let $relay_log_file_after_CM= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);

--let $assert_text= The relaylog file should not change if change master command was executed while SQL thread was running.
--let $assert_cond= "$relay_log_file_before_CM" = "$relay_log_file_after_CM"
--source include/assert.inc

--echo
--echo We now stop the SQL thread and ensure that the relaylog files
--echo are not deleted on doing a change master with a running IO thread.
--echo

--source include/stop_slave_sql.inc
--source include/start_slave_io.inc
CHANGE REPLICATION SOURCE TO SOURCE_DELAY= 20;

# Note down the active relaylog after change master
let $relay_log_file_after_CM= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);

--let $assert_text= The relaylog file should not change if change master command was executed while IO thread was running.
--let $assert_cond= "$relay_log_file_before_CM" = "$relay_log_file_after_CM"
--source include/assert.inc

--echo
--echo If the relay_log_file and relay_log_pos options are used, we dont purge
--echo relaylogs.
--echo

# Lets stop IO thread again to make sure we are not purging relay logs only
# because we have a use of relay_log_file/relay_log_pos options and not
# because one of the slave threads is running.

--source include/stop_slave_io.inc

let $relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
replace_result $relay_log_file RELAY_LOG_FILE;
eval CHANGE REPLICATION SOURCE TO RELAY_LOG_FILE= '$relay_log_file';

let $relay_log_pos= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1);
replace_result $relay_log_pos RELAY_LOG_POS;
eval CHANGE REPLICATION SOURCE TO RELAY_LOG_POS= $relay_log_pos;

let $relay_log_file_after_CM= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);

--let $assert_text= The relaylog file should not change if change master command contained relay_log_file or relay_log_pos option.
--let $assert_cond= "$relay_log_file_before_CM" = "$relay_log_file_after_CM"
--source include/assert.inc

--echo
--echo With both the threads stopped and no use of relay_log_file or
--echo relay_log_pos options, the relaylogs should be deleted.
--echo

CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD= 20;

let $relay_log_file_after_CM= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);

--let $assert_text= With both the threads stopped and no use of relay_log_file or relay_log_pos options in change master command, the relaylogs should be deleted.
--let $assert_cond= "$relay_log_file_before_CM" != "$relay_log_file_after_CM"
--source include/assert.inc

--echo
--echo cleanup
--echo

# Restore to default values now using the values saved before the tests.
# No need to record the default values in the result file.
--disable_query_log
eval CHANGE REPLICATION SOURCE TO SOURCE_DELAY= $delay_before_test;
eval CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD= $slave_heartbeat_timeout_before_test;
--enable_query_log

--source include/start_slave.inc
--source include/rpl_end.inc