Skip to content

Commit cc3e737

Browse files
committed
BUG#35639371 Replace old terminology in replication queries
In 8.2.0, several SQL queries related to replication are deprecated. The AdminAPI code that uses those queries must be updated accordingly to use the new syntax: - SHOW MASTER STATUS -> SHOW BINARY LOG STATUS - RESET MASTER -> RESET BINARY LOGS AND GTIDS - PURGE MASTER LOGS -> PURGE BINARY LOGS - SHOW MASTER LOGS -> SHOW BINARY LOGS Additionally, all unit-tests using replication-related queries and configurations must be updated. This patch handles those updates, to ensure the following list of changes are fullfilled: - START/STOP SLAVE: replaced by START/STOP REPLICA - SHOW SLAVE STATUS: replaced by SHOW REPLICA STATUS - SHOW SLAVE HOSTS: replaced by SHOW REPLICAS - RESET SLAVE: replaced by RESET REPLICA - CHANGE MASTER: replaced by CHANGE REPLICATION SOURCE - RESET MASTER: replaced by RESET BINARY LOGS AND GTIDS - SHOW MASTER STATUS: replaced by SHOW BINARY LOG STATUS - PURGE MASTER LOGS: replaced by PURGE BINARY LOGS - SHOW MASTER LOGS: replaced by SHOW BINARY LOGS - MASTER_AUTO_POSITION: replaced by SOURCE_AUTO_POSITION - MASTER_HOST: replaced by SOURCE_HOST - MASTER_BIND: replaced by SOURCE_BIND - MASTER_USER: replaced by SOURCE_USER - MASTER_PASSWORD: replaced by SOURCE_PASSWORD - MASTER_PORT: replaced by SOURCE_PORT - MASTER_CONNECT_RETRY: replaced by SOURCE_CONNECT_RETRY - MASTER_RETRY_COUNT: replaced by SOURCE_RETRY_COUNT - MASTER_DELAY: replaced by SOURCE_DELAY - MASTER_SSL: replaced by SOURCE_SSL - MASTER_SSL_CA: replaced by SOURCE_SSL_CA - MASTER_SSL_CAPATH: replaced by SOURCE_SSL_CAPATH - MASTER_SSL_CIPHER: replaced by SOURCE_SSL_CIPHER - MASTER_SSL_CRL: replaced by SOURCE_SSL_CRL - MASTER_SSL_CRLPATH: replaced by SOURCE_SSL_CRLPATH - MASTER_SSL_KEY: replaced by SOURCE_SSL_KEY - MASTER_SSL_VERIFY_SERVER_CERT: replaced by SOURCE_SSL_VERIFY_SERVER_CERT - MASTER_TLS_VERSION: replaced by SOURCE_TLS_VERSION - MASTER_TLS_CIPHERSUITES: replaced by SOURCE_TLS_CIPHERSUITES - MASTER_SSL_CERT: replaced by SOURCE_SSL_CERT - MASTER_PUBLIC_KEY_PATH: replaced by SOURCE_PUBLIC_KEY_PATH - GET_MASTER_PUBLIC_KEY: replaced by GET_SOURCE_PUBLIC_KEY - MASTER_HEARTBEAT_PERIOD: replaced by SOURCE_HEARTBEAT_PERIOD - MASTER_COMPRESSION_ALGORITHM: replaced by SOURCE_COMPRESSION_ALGORITHM - MASTER_ZSTD_COMPRESSION_LEVEL: replaced by SOURCE_ZSTD_COMPRESSION_LEVEL - MASTER_LOG_FILE: replaced by SOURCE_LOG_FILE - MASTER_LOG_POS: replaced by SOURCE_LOG_POS - MASTER_LOG_POS: replaced by SOURCE_LOG_POS - MASTER_LOG_FILE: replaced by SOURCE_LOG_FILE - DISABLE ON SLAVE: replaced by DISABLE ON REPLICA Change-Id: I1a312b3784bf4690d8c90fab4731d0b1ec9242d6
1 parent ba57d2d commit cc3e737

File tree

68 files changed

+532
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+532
-387
lines changed

modules/adminapi/cluster/cluster_impl.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4428,7 +4428,10 @@ int64_t Cluster_impl::prepare_clone_recovery(
44284428

44294429
// RESET MASTER to clear GTID_EXECUTED in case it's diverged, otherwise
44304430
// clone is not executed and GR rejects the instance
4431-
target_instance.query("RESET MASTER");
4431+
target_instance.query(shcore::str_format(
4432+
"RESET %s",
4433+
mysqlshdk::mysql::get_binary_logs_keyword(target_instance.get_version())
4434+
.c_str()));
44324435
}
44334436

44344437
// Make sure the Clone plugin is installed or uninstalled depending on the

modules/adminapi/common/common.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ void validate_replication_filters(const mysqlshdk::mysql::IInstance &instance,
253253
Cluster_type cluster_type) {
254254
// SHOW MASTER STATUS includes info about binlog filters, which filter
255255
// events from being written to the binlog, at the master
256-
auto result = instance.query("SHOW MASTER STATUS");
256+
auto result = instance.query(shcore::str_format(
257+
"SHOW %s STATUS",
258+
mysqlshdk::mysql::get_binary_logs_keyword(instance.get_version(), true)
259+
.c_str()));
257260

258261
while (auto row = result->fetch_one()) {
259262
if (!row->get_string(2, "").empty() || !row->get_string(3, "").empty())

modules/util/dump/schema_dumper.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include <array>
4242
#include <functional>
4343
#include <map>
44-
#include <regex>
4544
#include <unordered_set>
4645

4746
#include "my_sys.h"
@@ -51,8 +50,8 @@
5150
#include "mysqlshdk/include/shellcore/console.h"
5251
#include "mysqlshdk/libs/db/session.h"
5352
#include "mysqlshdk/libs/mysql/instance.h"
53+
#include "mysqlshdk/libs/mysql/replication.h"
5454
#include "mysqlshdk/libs/utils/debug.h"
55-
#include "mysqlshdk/libs/utils/strformat.h"
5655
#include "mysqlshdk/libs/utils/utils_general.h"
5756
#include "mysqlshdk/libs/utils/utils_lexing.h"
5857
#include "mysqlshdk/libs/utils/utils_sqlstring.h"
@@ -3444,8 +3443,10 @@ Instance_cache::Binlog Schema_dumper::binlog(bool quiet) {
34443443
Instance_cache::Binlog binlog;
34453444

34463445
try {
3447-
const auto result = m_mysql->query("SHOW MASTER STATUS;");
3448-
3446+
const auto result = m_mysql->query(shcore::str_format(
3447+
"SHOW %s STATUS", mysqlshdk::mysql::get_binary_logs_keyword(
3448+
m_mysql->get_server_version(), true)
3449+
.c_str()));
34493450
if (const auto row = result->fetch_one()) {
34503451
binlog.file = row->get_string(0); // File
34513452
binlog.position = row->get_uint(1); // Position

mysqlshdk/libs/mysql/replication.cc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,22 @@ bool get_channel_info(const mysqlshdk::mysql::IInstance &instance,
608608
std::vector<Slave_host> get_slaves(
609609
const mysqlshdk::mysql::IInstance &instance) {
610610
std::vector<Slave_host> slaves;
611+
std::shared_ptr<mysqlshdk::db::IResult> result;
611612

612-
auto result = instance.query("SHOW SLAVE HOSTS");
613+
if (instance.get_version() < utils::Version(8, 2, 0)) {
614+
result = instance.query("SHOW SLAVE HOSTS");
615+
} else {
616+
result = instance.query("SHOW REPLICAS");
617+
}
613618
while (auto row = result->fetch_one_named()) {
614619
Slave_host host;
615620
host.host = row.get_string("Host");
616621
host.port = row.get_uint("Port");
617-
host.uuid = row.get_string("Slave_UUID");
622+
if (instance.get_version() < utils::Version(8, 2, 0)) {
623+
host.uuid = row.get_string("Slave_UUID");
624+
} else {
625+
host.uuid = row.get_string("Replica_UUID");
626+
}
618627
slaves.push_back(std::move(host));
619628
}
620629

@@ -1047,6 +1056,15 @@ std::string get_replication_source_keyword(
10471056
}
10481057
}
10491058

1059+
std::string get_binary_logs_keyword(const mysqlshdk::utils::Version &version,
1060+
bool status) {
1061+
if (version < mysqlshdk::utils::Version(8, 2, 0)) {
1062+
return "MASTER";
1063+
} else {
1064+
return (status == true ? "BINARY LOG" : "BINARY LOGS AND GTIDS");
1065+
}
1066+
}
1067+
10501068
std::tuple<std::string, std::string> get_replication_source_keywords(
10511069
const mysqlshdk::utils::Version &version) {
10521070
if (version < mysqlshdk::utils::Version(8, 0, 23))

mysqlshdk/libs/mysql/replication.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,23 @@ std::string get_replica_keyword(const mysqlshdk::utils::Version &version);
476476
std::string get_replication_source_keyword(
477477
const mysqlshdk::utils::Version &version, bool command = false);
478478

479+
/**
480+
* Get the correct keyword in use for the replication configuration commands:
481+
* 'SHOW MASTER LOGS' / 'SHOW MASTER STATUS' / 'PURGE MASTER LOGS'
482+
* regarding the target instance version.
483+
*
484+
* Useful for the construction of queries or output/error messages.
485+
*
486+
* @param version Version of the target server.
487+
* @param command Boolean value to indicate if the keyword is for status
488+
* command: 'SHOW MASTER STATUS'
489+
*
490+
* @return a string with the right keyword to be used for the replication
491+
* configuration command
492+
*/
493+
std::string get_binary_logs_keyword(const mysqlshdk::utils::Version &version,
494+
bool status = false);
495+
479496
/**
480497
* Get the correct keywords in use for the replication configuration command:
481498
* 'change replication source/master' regarding the target instance version.

python/plugins/debug/sql_collector.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,11 @@ def filter_slave_master_info(row):
978978
kw_replica = "SLAVE"
979979
kw_replicas = "SLAVE HOSTS"
980980

981+
if self.session.version >= 80200:
982+
kw_binary_log = "BINARY LOG"
983+
else:
984+
kw_binary_log = "MASTER"
985+
981986
queries = [
982987
("global variables",
983988
"""SELECT g.variable_name name, g.variable_value value /*!80000, i.variable_source source*/
@@ -989,7 +994,7 @@ def filter_slave_master_info(row):
989994
# replication configuration
990995
"SHOW BINARY LOGS",
991996
f"SHOW {kw_replicas}",
992-
"SHOW MASTER STATUS",
997+
f"SHOW {kw_binary_log} STATUS",
993998
f"SHOW {kw_replica} STATUS",
994999
("replication master_info",
9951000
"""SELECT * FROM mysql.slave_master_info ORDER BY Channel_name""",

unittest/scripts/auto/js_adminapi/scripts/cluster_add_replica_instance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ shell.options.useWizards=0;
500500

501501
// clean the errant trxs
502502
session4.runSql("drop schema errant");
503-
session4.runSql("reset master");
503+
session4.runSql("RESET " + get_reset_binary_logs_keyword());
504504

505505
// purge binlogs
506506
var session1 = mysql.getSession(__sandbox_uri1);

unittest/scripts/auto/js_adminapi/scripts/cluster_addinstance.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ session.runSql("GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';");
324324
session.close();
325325
shell.connect(__sandbox_uri2);
326326

327-
session.runSql("CHANGE MASTER TO MASTER_HOST='" + hostname + "', MASTER_PORT=" + __mysql_sandbox_port1 + ", MASTER_USER='repl', MASTER_PASSWORD='password', MASTER_AUTO_POSITION=1, MASTER_SSL=1");
328-
session.runSql("START SLAVE");
327+
session.runSql("change " + get_replication_source_keyword() + " TO " + get_replication_option_keyword() + "_HOST='" + hostname + "', " + get_replication_option_keyword() + "_PORT=" + __mysql_sandbox_port1 + ", " + get_replication_option_keyword() + "_USER='repl', " + get_replication_option_keyword() + "_PASSWORD='password', " + get_replication_option_keyword() + "_AUTO_POSITION=1, " + get_replication_option_keyword() + "_SSL=1");
328+
session.runSql("START " + get_replica_keyword());
329329

330330
testutil.waitMemberTransactions(__mysql_sandbox_port2, __mysql_sandbox_port1);
331331

@@ -336,7 +336,7 @@ c.addInstance(__sandbox_uri2);
336336
//
337337
// Even if replication is not running but configured, the warning/error has to
338338
// be provided as implemented in BUG#29305551
339-
session.runSql("STOP SLAVE");
339+
session.runSql("STOP " + get_replica_keyword());
340340

341341
//@ AddInstance async replication error with channels stopped
342342
c.addInstance(__sandbox_uri2);
@@ -648,7 +648,7 @@ EXPECT_THROWS(function(){
648648

649649
shell.connect(__sandbox_uri2);
650650
dba.dropMetadataSchema({force:true, clearReadOnly:true});
651-
session.runSql("RESET MASTER");
651+
session.runSql("RESET " + get_reset_binary_logs_keyword());
652652

653653
//@<> BUG#31357039 Make sure that a note show when creating the cluster and adding an instance with local address specified {__os_type == 'windows' && !__replaying && !__recording}
654654
if (testutil.versionCheck(__version, "<", "8.0.21")) {

0 commit comments

Comments
 (0)