Skip to content

Commit c60528f

Browse files
author
Joao Gramacho
committed
BUG#21798355 SLOW STARTUP OF 5.7.X SLAVE WITH RELAY_LOG_RECOVERY = ON
AND MANY RELAY LOGS Problem ------- The slave initialization was scanning relay log files to update the Retrieved_Gtid_Set and the transaction parser state even when the relay_log_recovery option was set. Analysis -------- During the slave initialization, it opens the relay log to compute the Retrieved_Gtid_Set and to set the transaction parser in the correct state in order to keep track of already replicated GTID sets. The initialization procedure was performing the above actions even when the relay_log_recovery option was set. When the relay_log_recovery option is set, the slave I/O thread should not use the current relay log files and will base it initial state on the SQL thread state. If the I/O thread will not rely on relay log files, it is a waste of time to compute the Retrieved_Gtid_Set and the transaction parser state when the relay_log_recovery option is set. Fix --- The Retrieved_Gtid_Set and the transaction parser states are now initialized only if the relay_log_recovery option is not set.
1 parent b1d77ce commit c60528f

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
include/master-slave.inc
2+
Warnings:
3+
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
4+
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
5+
[connection master]
6+
CALL mtr.add_suppression('Recovery from master pos');
7+
CREATE TABLE t1 (c1 INT);
8+
INSERT INTO t1 VALUES (1);
9+
FLUSH LOCAL BINARY LOGS;
10+
INSERT INTO t1 VALUES (1);
11+
DROP TABLE t1;
12+
[connection slave]
13+
include/start_slave_io.inc
14+
[connection master]
15+
include/sync_slave_io_with_master.inc
16+
include/rpl_restart_server.inc [server_number=2 parameters: --relay_log_recovery=ON]
17+
include/assert_grep.inc [Found no lines about reading events on the relay log.]
18+
[connection slave]
19+
include/start_slave.inc
20+
include/rpl_end.inc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# ==== Purpose ====
2+
#
3+
# This test will verify if a slave will skip the transaction boundary parser
4+
# and the Retrieved_Gtid_Set initialization when relay_log_recovery is set.
5+
#
6+
# ==== Related Bugs and Worklogs ====
7+
#
8+
# BUG#21798355 SLOW STARTUP OF 5.7.X SLAVE WITH RELAY_LOG_RECOVERY = ON
9+
# AND MANY RELAY LOGS
10+
11+
# This test case is binary log format agnostic
12+
--source include/have_binlog_format_row.inc
13+
--let $rpl_skip_start_slave=1
14+
--source include/master-slave.inc
15+
# Suppress recovery warning messages
16+
CALL mtr.add_suppression('Recovery from master pos');
17+
18+
# Insert some content on the master
19+
CREATE TABLE t1 (c1 INT);
20+
INSERT INTO t1 VALUES (1);
21+
22+
# Rotate the binary log to have events on more than one relay log file
23+
FLUSH LOCAL BINARY LOGS;
24+
INSERT INTO t1 VALUES (1);
25+
DROP TABLE t1;
26+
27+
# Start and sync the I/O thread before restarting the slave
28+
--source include/rpl_connection_slave.inc
29+
--source include/start_slave_io.inc
30+
--source include/rpl_connection_master.inc
31+
--source include/sync_slave_io_with_master.inc
32+
33+
# Restart the slave enabling relay_log_recovery
34+
--let $rpl_server_number= 2
35+
--let $rpl_server_parameters= --relay_log_recovery=ON
36+
--source include/rpl_restart_server.inc
37+
38+
# File to GREP
39+
--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
40+
# Show entries only after the last occurrence of the following pattern
41+
--let $assert_only_after=.* \[Note\] Shutting down slave threads
42+
# Assert that there is no expected note log line about reading relay log events
43+
--let $assert_count= 0
44+
--let $assert_select=.* \[Note\] .* events read in relaylog file .*
45+
--let $assert_text= Found no lines about reading events on the relay log.
46+
--source include/assert_grep.inc
47+
48+
# Cleanup
49+
--source include/rpl_connection_slave.inc
50+
--source include/start_slave.inc
51+
52+
--source include/rpl_end.inc

sql/rpl_rli.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -2096,8 +2096,13 @@ a file name for --relay-log-index option.", opt_relaylog_index_name);
20962096
be useful to ensure the Retrieved_Gtid_Set behavior when auto
20972097
positioning is disabled (we could have transactions spanning multiple
20982098
relay log files in this case).
2099+
We will skip this initialization if relay_log_recovery is set in order
2100+
to save time, as neither the GTIDs nor the transaction_parser state
2101+
would be useful when the relay log will be cleaned up later when calling
2102+
init_recovery.
20992103
*/
2100-
if (!gtid_retrieved_initialized &&
2104+
if (!is_relay_log_recovery &&
2105+
!gtid_retrieved_initialized &&
21012106
relay_log.init_gtid_sets(&gtid_set, NULL,
21022107
opt_slave_sql_verify_checksum,
21032108
true/*true=need lock*/,

0 commit comments

Comments
 (0)