Skip to content

Commit 41d911a

Browse files
committed
Merge branch 'mysql-5.7' into mysql-8.0
2 parents 7ff1ab0 + 12eeb4a commit 41d911a

7 files changed

+86
-39
lines changed

mysql-test/extra/rpl_tests/rpl_ignore_super_read_only.test

+33-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# 11) Execute 'FLUSH BINARY LOGS' command (with GTID_MODE=ON will assert)
1717
# 12) Execute 'SET GLOBAL gtid_purged='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1''
1818
# command
19+
# 13) Restart Slave and verify that slave_master_info table is updated during
20+
# shutdown.
1921
# 14) Check that replication works fine
2022
# 15) Restore GLOBAL super_read_only to 0
2123
#
@@ -27,7 +29,8 @@
2729
# MANY RPL CMDS.
2830
# Bug#26414532: MYSQLRPLSYNC ERRORS OUT BECAUSE SLAVE IS USING --SUPER-READ-ONLY
2931
# OPTION
30-
#
32+
# Bug#27675107: SUPER_READ_ONLY WITH MASTER_INFO_REPOSITORY=TABLE BREAKS
33+
# REPLICATION ON RESTART
3134

3235
if (!$autocommit_opt)
3336
{
@@ -40,9 +43,9 @@ INSERT INTO t1 VALUES(1);
4043
DROP TABLE t1;
4144
--source include/sync_slave_sql_with_master.inc
4245

43-
SET @saved_value_super= @@GLOBAL.super_read_only;
44-
SET @saved_value= @@GLOBAL.read_only;
45-
SET @saved_autocommit= @@GLOBAL.autocommit;
46+
--let $saved_value_super= `SELECT @@GLOBAL.super_read_only`
47+
--let $saved_value= `SELECT @@GLOBAL.read_only`
48+
--let $saved_autocommit= `SELECT @@GLOBAL.autocommit`
4649
SET GLOBAL super_read_only= 1;
4750
--eval SET AUTOCOMMIT= $autocommit_opt
4851
SHOW VARIABLES like '%autocommit%';
@@ -114,18 +117,40 @@ RESET MASTER;
114117
--replace_result $master_uuid MASTER_UUID
115118
--eval SET GLOBAL gtid_purged= '$master_uuid:1'
116119

120+
--echo ####################################################################
121+
--echo # Test Case9: Server Restart
122+
--echo ####################################################################
123+
124+
# Restart Slave and verify that slave_master_info table is updated during shutdown.
125+
--let $io_pos_before_restart = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1)
126+
--let $rpl_server_number = 2
127+
--source include/rpl_restart_server.inc
128+
--let $io_pos_after_restart = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1)
129+
130+
# Assert that IO thread Read_Master_Log_Pos before and after restart are same.
131+
--let $assert_text= Read_Master_Log_Pos before and after restart are same.
132+
--let $assert_cond= $io_pos_before_restart = $io_pos_after_restart
133+
--source include/assert.inc
134+
135+
# Restart slave threads
136+
--source include/start_slave.inc
137+
--source include/rpl_connection_master.inc
138+
--source include/sync_slave_sql_with_master.inc
117139

118140
--echo "Clean up"
119141
# Reset slave to clean state
120-
SET AUTOCOMMIT= @saved_autocommit;
121-
SET GLOBAL super_read_only= @saved_value_super;
122-
SET GLOBAL read_only= @saved_value;
142+
--replace_result $saved_autocommit SAVED_AUTOCOMMIT
143+
--eval SET AUTOCOMMIT= $saved_autocommit
144+
--replace_result $saved_value_super SAVED_SUPER_READ_ONLY
145+
--eval SET GLOBAL super_read_only= $saved_value_super
146+
--replace_result $saved_value SAVED_READ_ONLY
147+
--eval SET GLOBAL read_only= $saved_value
123148

124149
# Start fresh slave
125150
--source include/stop_slave.inc
126151
--replace_result $MASTER_MYPORT MASTER_PORT
127152
--replace_column 2 ####
128-
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root';
153+
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root'
129154
--source include/start_slave.inc
130155

131156
--source include/rpl_connection_master.inc

mysql-test/suite/rpl/r/rpl_operation_ignore_super_read_only.result

+24-14
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ CREATE TABLE t1(a INT);
88
INSERT INTO t1 VALUES(1);
99
DROP TABLE t1;
1010
include/sync_slave_sql_with_master.inc
11-
SET @saved_value_super= @@GLOBAL.super_read_only;
12-
SET @saved_value= @@GLOBAL.read_only;
13-
SET @saved_autocommit= @@GLOBAL.autocommit;
1411
SET GLOBAL super_read_only= 1;
1512
SET AUTOCOMMIT= ON;
1613
SHOW VARIABLES like '%autocommit%';
@@ -56,12 +53,20 @@ RESET MASTER;
5653
# Test Case8: SET GLOBAL GTID_PURGED command
5754
####################################################################
5855
SET GLOBAL gtid_purged= 'MASTER_UUID:1';
56+
####################################################################
57+
# Test Case9: Server Restart
58+
####################################################################
59+
include/rpl_restart_server.inc [server_number=2]
60+
include/assert.inc [Read_Master_Log_Pos before and after restart are same.]
61+
include/start_slave.inc
62+
[connection master]
63+
include/sync_slave_sql_with_master.inc
5964
"Clean up"
60-
SET AUTOCOMMIT= @saved_autocommit;
61-
SET GLOBAL super_read_only= @saved_value_super;
62-
SET GLOBAL read_only= @saved_value;
65+
SET AUTOCOMMIT= SAVED_AUTOCOMMIT;
66+
SET GLOBAL super_read_only= SAVED_SUPER_READ_ONLY;
67+
SET GLOBAL read_only= SAVED_READ_ONLY;
6368
include/stop_slave.inc
64-
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root';;
69+
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root';
6570
Warnings:
6671
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
6772
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.
@@ -74,9 +79,6 @@ CREATE TABLE t1(a INT);
7479
INSERT INTO t1 VALUES(1);
7580
DROP TABLE t1;
7681
include/sync_slave_sql_with_master.inc
77-
SET @saved_value_super= @@GLOBAL.super_read_only;
78-
SET @saved_value= @@GLOBAL.read_only;
79-
SET @saved_autocommit= @@GLOBAL.autocommit;
8082
SET GLOBAL super_read_only= 1;
8183
SET AUTOCOMMIT= OFF;
8284
SHOW VARIABLES like '%autocommit%';
@@ -122,12 +124,20 @@ RESET MASTER;
122124
# Test Case8: SET GLOBAL GTID_PURGED command
123125
####################################################################
124126
SET GLOBAL gtid_purged= 'MASTER_UUID:1';
127+
####################################################################
128+
# Test Case9: Server Restart
129+
####################################################################
130+
include/rpl_restart_server.inc [server_number=2]
131+
include/assert.inc [Read_Master_Log_Pos before and after restart are same.]
132+
include/start_slave.inc
133+
[connection master]
134+
include/sync_slave_sql_with_master.inc
125135
"Clean up"
126-
SET AUTOCOMMIT= @saved_autocommit;
127-
SET GLOBAL super_read_only= @saved_value_super;
128-
SET GLOBAL read_only= @saved_value;
136+
SET AUTOCOMMIT= SAVED_AUTOCOMMIT;
137+
SET GLOBAL super_read_only= SAVED_SUPER_READ_ONLY;
138+
SET GLOBAL read_only= SAVED_READ_ONLY;
129139
include/stop_slave.inc
130-
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root';;
140+
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root';
131141
Warnings:
132142
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
133143
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.

mysql-test/suite/rpl/t/rpl_operation_ignore_super_read_only.test

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
# MANY RPL CMDS.
2020
# Bug#26414532: MYSQLRPLSYNC ERRORS OUT BECAUSE SLAVE IS USING --SUPER-READ-ONLY
2121
# OPTION
22-
#
22+
# Bug#27675107: SUPER_READ_ONLY WITH MASTER_INFO_REPOSITORY=TABLE BREAKS
23+
# REPLICATION ON RESTART
2324

2425
# Test in this file only makes sense in standard replication,
2526
# so it is skipped in group replication.

sql/rpl_info_table.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -160,7 +160,7 @@ int Rpl_info_table::do_init_info(enum_find_method method, uint instance) {
160160
/*
161161
Unlocks and closes the rpl_info table.
162162
*/
163-
access->close_table(thd, table, &backup, error);
163+
error = access->close_table(thd, table, &backup, error) || error;
164164
thd->variables.sql_mode = saved_mode;
165165
thd->variables.option_bits = saved_options;
166166
access->drop_thd(thd);
@@ -260,7 +260,7 @@ int Rpl_info_table::do_flush_info(const bool force) {
260260
/*
261261
Unlocks and closes the rpl_info table.
262262
*/
263-
access->close_table(thd, table, &backup, error);
263+
error = access->close_table(thd, table, &backup, error) || error;
264264
thd->is_operating_substatement_implicitly = false;
265265
thd->variables.sql_mode = saved_mode;
266266
thd->variables.option_bits = saved_options;
@@ -310,7 +310,7 @@ int Rpl_info_table::do_clean_info() {
310310
/*
311311
Unlocks and closes the rpl_info table.
312312
*/
313-
access->close_table(thd, table, &backup, error);
313+
error = access->close_table(thd, table, &backup, error) || error;
314314
thd->variables.sql_mode = saved_mode;
315315
thd->variables.option_bits = saved_options;
316316
access->drop_thd(thd);
@@ -404,7 +404,7 @@ int Rpl_info_table::do_reset_info(uint nparam, const char *param_schema,
404404
/*
405405
Unlocks and closes the rpl_info table.
406406
*/
407-
info->access->close_table(thd, table, &backup, error);
407+
error = info->access->close_table(thd, table, &backup, error) || error;
408408
thd->variables.sql_mode = saved_mode;
409409
thd->variables.option_bits = saved_options;
410410
info->access->drop_thd(thd);
@@ -560,7 +560,7 @@ bool Rpl_info_table::do_count_info(uint nparam, const char *param_schema,
560560
/*
561561
Unlocks and closes the rpl_info table.
562562
*/
563-
info->access->close_table(thd, table, &backup, error);
563+
error = info->access->close_table(thd, table, &backup, error) || error;
564564
thd->variables.sql_mode = saved_mode;
565565
info->access->drop_thd(thd);
566566
delete info;
@@ -715,7 +715,7 @@ bool Rpl_info_table::do_update_is_transactional() {
715715
error = false;
716716

717717
end:
718-
access->close_table(thd, table, &backup, 0);
718+
error = access->close_table(thd, table, &backup, 0) || error;
719719
thd->variables.sql_mode = saved_mode;
720720
thd->variables.option_bits = saved_options;
721721
access->drop_thd(thd);

sql/rpl_info_table_access.cc

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -94,12 +94,17 @@ void Rpl_info_table_access::before_open(THD *thd) {
9494
committed. In this case, the changes were not done on behalf of
9595
any user transaction and if not finished, there would be pending
9696
changes.
97+
98+
@return
99+
@retval false Success
100+
@retval true Failure
97101
*/
98-
void Rpl_info_table_access::close_table(THD *thd, TABLE *table,
102+
bool Rpl_info_table_access::close_table(THD *thd, TABLE *table,
99103
Open_tables_backup *backup,
100104
bool error) {
101105
DBUG_ENTER("Rpl_info_table_access::close_table");
102-
System_table_access::close_table(thd, table, backup, error, thd_created);
106+
bool res =
107+
System_table_access::close_table(thd, table, backup, error, thd_created);
103108

104109
DBUG_EXECUTE_IF("slave_crash_after_commit_no_atomic_ddl", {
105110
if (thd->slave_thread && thd->rli_slave && thd->rli_slave->current_event &&
@@ -112,7 +117,7 @@ void Rpl_info_table_access::close_table(THD *thd, TABLE *table,
112117
}
113118
});
114119

115-
DBUG_VOID_RETURN;
120+
DBUG_RETURN(res);
116121
}
117122

118123
/**
@@ -355,6 +360,11 @@ THD *Rpl_info_table_access::create_thd() {
355360
if (!thd) {
356361
thd = System_table_access::create_thd();
357362
thd->system_thread = SYSTEM_THREAD_INFO_REPOSITORY;
363+
/*
364+
Set the skip_readonly_check flag as this thread should not be
365+
blocked by super_read_only check during ha_commit_trans.
366+
*/
367+
thd->set_skip_readonly_check();
358368
thd_created = true;
359369
}
360370

@@ -371,6 +381,7 @@ void Rpl_info_table_access::drop_thd(THD *thd) {
371381
DBUG_ENTER("Rpl_info::drop_thd");
372382

373383
if (thd_created) {
384+
thd->reset_skip_readonly_check();
374385
System_table_access::drop_thd(thd);
375386
thd_created = false;
376387
}

sql/rpl_info_table_access.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -48,7 +48,7 @@ class Rpl_info_table_access : public System_table_access {
4848
@param[in] thd Thread requesting to open the table
4949
*/
5050
void before_open(THD *thd);
51-
void close_table(THD *thd, TABLE *table, Open_tables_backup *backup,
51+
bool close_table(THD *thd, TABLE *table, Open_tables_backup *backup,
5252
bool error);
5353
enum enum_return_id find_info(Rpl_info_values *field_values, TABLE *table);
5454
enum enum_return_id scan_info(TABLE *table, uint instance);

sql/rpl_table_access.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -122,13 +122,13 @@ bool System_table_access::close_table(THD *thd, TABLE *table,
122122
}
123123
if (need_commit) {
124124
if (error)
125-
res = ha_rollback_trans(thd, true);
125+
res = ha_rollback_trans(thd, true) || res;
126126
else {
127127
/*
128128
To make the commit not to block with global read lock set
129129
"ignore_global_read_lock" flag to true.
130130
*/
131-
res = ha_commit_trans(thd, true, true);
131+
res = ha_commit_trans(thd, true, true) || res;
132132
}
133133
}
134134
/*

0 commit comments

Comments
 (0)