Commit 90c3b283 authored by Brandon Nesterenko's avatar Brandon Nesterenko

MDEV-20122: Deprecate MASTER_USE_GTID=Current_Pos to favor new MASTER_DEMOTE_TO_SLAVE option

New Feature:
========
This feature adds a safe replacement to the
MASTER_USE_GTID=Current_Pos option for CHANGE MASTER TO as
MASTER_DEMOTE_TO_SLAVE=<bool>. The use case of Current_Pos is to
transition a master to become a slave; however, can break
replication state if the slave executes local transactions due to
actively updating gtid_current_pos with gtid_binlog_pos and
gtid_slave_pos.

MASTER_DEMOTE_TO_SLAVE changes this use case by forcing users to set
Using_Gtid=Slave_Pos and merging gtid_binlog_pos into gtid_slave_pos
once at CHANGE MASTER TO time. Note that if gtid_slave_pos is more
recent than gtid_binlog_pos (as in the case of chain replication),
the replication state should be preserved.

Additionally, deprecate the `Current_Pos` option of MASTER_USE_GTID
to suggest the safe alternative option MASTER_DEMOTE_TO_SLAVE=TRUE.

Reviewed By:
============
Andrei Elkin <andrei.elkin@mariadb.com>
parent 5ab5ff08
......@@ -69,6 +69,8 @@ INSERT INTO t2 VALUES (5, "i1a");
connection server_4;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
SELECT * FROM t1 ORDER BY a;
a b
......@@ -89,6 +91,8 @@ connection server_2;
include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_4,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
connection server_4;
UPDATE t2 SET b="j1a" WHERE a=5;
......@@ -117,6 +121,8 @@ include/save_master_gtid.inc
connection server_3;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_4,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
include/sync_with_master_gtid.inc
SELECT * FROM t2 ORDER BY a;
......
......@@ -26,4 +26,9 @@ connection master;
CHANGE MASTER TO MASTER_USER='root', MASTER_SSL=0, MASTER_SSL_CA='', MASTER_SSL_CERT='',
MASTER_SSL_KEY='', MASTER_SSL_CRL='', MASTER_SSL_CRLPATH='';
CHANGE MASTER TO MASTER_USER='root', MASTER_PASSWORD='', MASTER_SSL=0;
"Usage of CURRENT_POS in CHANGE MASTER MASTER_USE_GTID is dreprecated.
CHANGE MASTER TO MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
CHANGE MASTER TO MASTER_USE_GTID=SLAVE_POS;
include/rpl_end.inc
......@@ -48,7 +48,11 @@ INSERT INTO t2 VALUES (2, "switch1");
INSERT INTO t3 VALUES (202, "switch1 b");
connection slave2;
CHANGE MASTER 'slave1' TO master_port=MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
CHANGE MASTER 'slave2' TO master_port=MYPORT_2, master_host='127.0.0.1', master_user='root', master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
SET default_master_connection = 'slave1';
START SLAVE;
include/wait_for_slave_to_start.inc
......@@ -76,6 +80,8 @@ connection slave2;
include/sync_with_master_gtid.inc
connection slave1;
CHANGE MASTER TO master_port=MYPORT_4, master_host='127.0.0.1', master_user='root', master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
START SLAVE;
SELECT * FROM t1 ORDER BY a;
a b
......
......@@ -191,17 +191,17 @@ SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR
FROM performance_schema.events_statements_summary_by_digest
ORDER BY DIGEST_TEXT;
SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR
test 27a9ab161a63050c84a63c6f77ebeb33 EXPLAIN SELECT * FROM `test` . `v1` 1
test ab0ab27c04f3a294feb86bede4331f86 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1
test 2e722346a5c2ef820946bcd04ccac208 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1
test 07baf2264db30b6b25302603436ebe82 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1
test 3a7dbc963635ab0de6e160e0a4212bce EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1
test 6b845c2e3a7421997e3b610d14b5c842 SELECT * FROM `test` . `v1` 1
test cb2ee099edbf6e0e5ee6ae14f3b1498a SELECT * FROM `test` . `v1` WHERE `a` = ? 1
test e2dc5a300d2ba54ebb987a2ca6b90d93 SELECT * FROM `test` . `v1` WHERE `b` > ? 1
test c68e0f99323f7bb7732c7b5cf32c0ec2 SELECT `a` , `b` FROM `test` . `v1` 1
test 43c5de955c9a72d2bb6f49db5c0ad3e7 SELECT `b` , `a` FROM `test` . `v1` 1
test 1678258ba15f7ccc63fd7b833763914a TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
test 333a53e537d74bf74dd28c78ad5b23dd EXPLAIN SELECT * FROM `test` . `v1` 1
test 1fb578da66e6583bae8e64061486f1b1 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1
test 923bca939a55826e231e1335016ba418 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1
test 6fa6d75432fd499d1c7d6f964c8310a2 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1
test 3421da1ec8ecb8cac97e12a0609f73cb EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1
test c2f68fd41bfbf3acd52eb5e7306b0c00 SELECT * FROM `test` . `v1` 1
test dd68812cbe4c1ed5a38921222981f8c5 SELECT * FROM `test` . `v1` WHERE `a` = ? 1
test 7563bcc32c6d0d872c8d9f0bf7717e6a SELECT * FROM `test` . `v1` WHERE `b` > ? 1
test 0817c53833dc6adbca581e8fe4c598c7 SELECT `a` , `b` FROM `test` . `v1` 1
test a5f13903c70812ae08fa8c084e9cd503 SELECT `b` , `a` FROM `test` . `v1` 1
test 66b14a14f2a42e1335dd28dfad8ea084 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
DROP TABLE test.v1;
CREATE VIEW test.v1 AS SELECT * FROM test.t1;
EXPLAIN SELECT * from test.v1;
......@@ -248,19 +248,19 @@ SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR
FROM performance_schema.events_statements_summary_by_digest
ORDER BY DIGEST_TEXT;
SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR
test 342cd5e41944d5f857f92b1e374857de CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1
test 2653f30030efcb6125121daa8eadf418 DROP TABLE `test` . `v1` 1
test 27a9ab161a63050c84a63c6f77ebeb33 EXPLAIN SELECT * FROM `test` . `v1` 2
test ab0ab27c04f3a294feb86bede4331f86 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2
test 2e722346a5c2ef820946bcd04ccac208 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2
test 07baf2264db30b6b25302603436ebe82 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2
test 3a7dbc963635ab0de6e160e0a4212bce EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2
test 6b845c2e3a7421997e3b610d14b5c842 SELECT * FROM `test` . `v1` 2
test cb2ee099edbf6e0e5ee6ae14f3b1498a SELECT * FROM `test` . `v1` WHERE `a` = ? 2
test e2dc5a300d2ba54ebb987a2ca6b90d93 SELECT * FROM `test` . `v1` WHERE `b` > ? 2
test a13cfeda6d474d29546719d76dcfa831 SELECT SCHEMA_NAME , `DIGEST` , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1
test c68e0f99323f7bb7732c7b5cf32c0ec2 SELECT `a` , `b` FROM `test` . `v1` 2
test 43c5de955c9a72d2bb6f49db5c0ad3e7 SELECT `b` , `a` FROM `test` . `v1` 2
test 1678258ba15f7ccc63fd7b833763914a TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
test 98531b331031b84ddfbb2de8b601a704 CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1
test 5352d7d117e97fecd312e354e9e290ce DROP TABLE `test` . `v1` 1
test 333a53e537d74bf74dd28c78ad5b23dd EXPLAIN SELECT * FROM `test` . `v1` 2
test 1fb578da66e6583bae8e64061486f1b1 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2
test 923bca939a55826e231e1335016ba418 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2
test 6fa6d75432fd499d1c7d6f964c8310a2 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2
test 3421da1ec8ecb8cac97e12a0609f73cb EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2
test c2f68fd41bfbf3acd52eb5e7306b0c00 SELECT * FROM `test` . `v1` 2
test dd68812cbe4c1ed5a38921222981f8c5 SELECT * FROM `test` . `v1` WHERE `a` = ? 2
test 7563bcc32c6d0d872c8d9f0bf7717e6a SELECT * FROM `test` . `v1` WHERE `b` > ? 2
test 21c19dd7ef5b894f3e32d0585cb3007f SELECT SCHEMA_NAME , `DIGEST` , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1
test 0817c53833dc6adbca581e8fe4c598c7 SELECT `a` , `b` FROM `test` . `v1` 2
test a5f13903c70812ae08fa8c084e9cd503 SELECT `b` , `a` FROM `test` . `v1` 2
test 66b14a14f2a42e1335dd28dfad8ea084 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
DROP VIEW test.v1;
DROP TABLE test.t1;
......@@ -8,5 +8,5 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
####################################
SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long;
event_name digest digest_text sql_text
statement/sql/select 1fd0cdb6b5aa22bd0809a39b2dc2ac70 SELECT ? + ? + SELECT ...
statement/sql/truncate 0a9c405cebde6df4be315dae86ff398a TRUNCATE TABLE truncat...
statement/sql/select 96a6bb95edaf100857f09c968aca354b SELECT ? + ? + SELECT ...
statement/sql/truncate c1d647bb870f2c63c22a16707bb8aee3 TRUNCATE TABLE truncat...
#
# This file tests that a master can be demoted to a slave using
# CHANGE MASTER TO MASTER_DEMOTE_TO_SLAVE=1 and replication will work correctly
# afterwards.
#
# param $ignore_domain_ids : List of GTID domain ids to use for
# CHANGE MASTER TO IGNORE_DOMAIN_IDS
#
--let $include_filename= rpl_change_master_demote.inc
--source include/begin_include_file.inc
--echo ##############################################
--echo # Connection semantics change:
--echo # * True primary is now connection 'slave'
--echo # * True replica is now connection 'master'
--echo ##############################################
--connection master
SELECT VARIABLE_NAME, GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE VARIABLE_NAME LIKE 'gtid_binlog_pos' OR VARIABLE_NAME LIKE 'gtid_slave_pos' OR VARIABLE_NAME LIKE 'gtid_current_pos' ORDER BY VARIABLE_NAME ASC;
--let $extra_cm_args=
if (`SELECT strcmp("$ignore_domain_ids","") != 0`)
{
--let $extra_cm_args=, ignore_domain_ids=($ignore_domain_ids)
}
--echo # First ensure gtid_slave_pos after master_demote_to_slave matches
--echo # gtid_current_pos calculation
--let $current_pos= `SELECT @@gtid_current_pos`
--replace_result $SLAVE_MYPORT SLAVE_PORT
--eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SLAVE_MYPORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1 $extra_cm_args
SELECT VARIABLE_NAME, GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE VARIABLE_NAME LIKE 'gtid_binlog_pos' OR VARIABLE_NAME LIKE 'gtid_slave_pos' OR VARIABLE_NAME LIKE 'gtid_current_pos' ORDER BY VARIABLE_NAME ASC;
--let $slave_pos= `SELECT @@gtid_slave_pos`
--echo # Validating gtid_slave_pos == gtid_binlog_pos..
if ($slave_pos != $current_pos)
{
SELECT VARIABLE_NAME, GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE VARIABLE_NAME LIKE 'gtid_binlog_pos' OR VARIABLE_NAME LIKE 'gtid_slave_pos' OR VARIABLE_NAME LIKE 'gtid_current_pos' ORDER BY VARIABLE_NAME ASC;
die gtid_slave_pos calculation after master_demote_to_slave=1 differs from gtid_current_pos;
}
--echo # ..success
--source include/start_slave.inc
--connection slave
--source include/stop_slave.inc
--echo # Ensuring replication works correctly after role swap
--connection slave
set session gtid_domain_id= 0;
CREATE TABLE repl_t (a int);
INSERT INTO repl_t VALUES (1);
--source include/save_master_gtid.inc
--connection master
--source include/sync_with_master_gtid.inc
--echo # Validating that replication works..
--let $n_replicated_rows= query_get_value(SELECT COUNT(*) FROM repl_t, COUNT(*), 1)
if ($n_replicated_rows != 1)
{
die "Replication is broken";
}
--echo # ..success
--echo # Cleaning up replication check data
--connection slave
DROP TABLE repl_t;
--source include/save_master_gtid.inc
--connection master
--source include/sync_with_master_gtid.inc
SELECT VARIABLE_NAME, GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE VARIABLE_NAME LIKE 'gtid_binlog_pos' OR VARIABLE_NAME LIKE 'gtid_slave_pos' OR VARIABLE_NAME LIKE 'gtid_current_pos' ORDER BY VARIABLE_NAME ASC;
--echo ##############################################
--echo # Connection semantics change:
--echo # * True primary is back to connection 'master'
--echo # * True replica is back to connection 'slave'
--echo ##############################################
--connection master
--source include/stop_slave.inc
--connection slave
--replace_result $MASTER_MYPORT MASTER_PORT
--eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$MASTER_MYPORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1
--source include/start_slave.inc
--let $include_filename= rpl_change_master_demote.inc
--source include/end_include_file.inc
......@@ -5,6 +5,8 @@ SET GLOBAL LOG_WARNINGS=2;
connection slave;
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
connection master;
"Test Case 1: Start binlog_dump to slave_server(#), pos(master-bin.000001, ###), using_gtid(1), gtid('')"
......
......@@ -26,4 +26,9 @@ connection master;
CHANGE MASTER TO MASTER_USER='root', MASTER_SSL=0, MASTER_SSL_CA='', MASTER_SSL_CERT='',
MASTER_SSL_KEY='', MASTER_SSL_CRL='', MASTER_SSL_CRLPATH='';
CHANGE MASTER TO MASTER_USER='root', MASTER_PASSWORD='', MASTER_SSL=0;
"Usage of CURRENT_POS in CHANGE MASTER MASTER_USE_GTID is dreprecated.
CHANGE MASTER TO MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
CHANGE MASTER TO MASTER_USE_GTID=SLAVE_POS;
include/rpl_end.inc
This diff is collapsed.
......@@ -69,6 +69,8 @@ INSERT INTO t2 VALUES (5, "i1a");
connection server_4;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
SELECT * FROM t1 ORDER BY a;
a b
......@@ -89,6 +91,8 @@ connection server_2;
include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_4,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
connection server_4;
UPDATE t2 SET b="j1a" WHERE a=5;
......@@ -117,6 +121,8 @@ include/save_master_gtid.inc
connection server_3;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_4,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
include/sync_with_master_gtid.inc
SELECT * FROM t2 ORDER BY a;
......
......@@ -15,6 +15,8 @@ SET sql_log_bin=1;
include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
connection server_1;
INSERT INTO t1 VALUES (2,1);
INSERT INTO t1 VALUES (3,1);
......
......@@ -74,6 +74,8 @@ INSERT INTO t1 VALUES (2);
SET sql_log_bin = 1;
INSERT INTO t1 VALUES (3);
CHANGE MASTER TO master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
BEGIN;
SET GLOBAL gtid_slave_pos = "100-100-100";
ERROR 25000: You are not allowed to execute this command in a transaction
......
......@@ -4,6 +4,8 @@ CREATE TABLE t1 (i INT);
connection slave;
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID= current_pos, MASTER_DELAY= 10;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
connection master;
INSERT INTO t1 VALUES (1);
......
......@@ -13,15 +13,23 @@ END|
connection server_2;
include/stop_slave.inc
CHANGE MASTER TO master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
connection server_3;
include/stop_slave.inc
CHANGE MASTER TO master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
connection server_4;
include/stop_slave.inc
CHANGE MASTER TO master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
connection server_5;
include/stop_slave.inc
CHANGE MASTER TO master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
connection server_1;
SET gtid_domain_id= 1;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
......@@ -340,6 +348,8 @@ a b
connection server_1;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_2,
master_user = "root", master_use_gtid = current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
SELECT * FROM t1 ORDER BY a;
a
......
......@@ -13,6 +13,8 @@ reset slave all;
connection server_1;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_2,
master_user='root', MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
include/wait_for_slave_to_start.inc
connection server_2;
......@@ -23,6 +25,8 @@ flush logs;
connection server_3;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_2,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
select * from t1 order by n;
n
......@@ -58,11 +62,15 @@ Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'Cur
connection server_2;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_1,
master_user = 'root', MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
connection server_3;
include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_1,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
connection server_1;
drop table t1;
......
......@@ -45,6 +45,8 @@ SET GLOBAL gtid_slave_pos= '0-2-10';
connection server_1;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_2,
master_user= 'root', master_use_gtid=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
START SLAVE;
connection server_2;
INSERT INTO t1 VALUES (11);
......@@ -74,6 +76,8 @@ connection server_2;
INSERT INTO t1 VALUES (22);
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_1,
master_user= 'root', master_use_gtid=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
START SLAVE;
SET sql_log_bin= 0;
CALL mtr.add_suppression("which is not in the master's binlog. Since the master's binlog contains GTIDs with higher sequence numbers, it probably means that the slave has diverged");
......
......@@ -10,6 +10,8 @@ SET sql_log_bin= 0;
INSERT INTO t1 VALUES (1);
SET sql_log_bin= 1;
CHANGE MASTER TO master_use_gtid= current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
connection master;
CREATE TEMPORARY TABLE t2 LIKE t1;
INSERT INTO t2 VALUE (1);
......
......@@ -22,6 +22,8 @@ include/stop_slave.inc
connection server_1;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SLAVE_PORT,
master_user = 'root', master_use_gtid = current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
START SLAVE;
include/wait_for_slave_to_start.inc
connection server_2;
......@@ -54,6 +56,8 @@ include/save_master_gtid.inc
connection server_2;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
master_use_gtid = current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
START SLAVE;
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
......
......@@ -2,6 +2,8 @@ include/rpl_init.inc [topology=1->2]
connection server_2;
include/stop_slave.inc
CHANGE MASTER TO master_use_gtid= current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
connection server_1;
CREATE TABLE t1 (a INT);
......
......@@ -59,6 +59,8 @@ Variable_name Value
gtid_binlog_state
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
SHOW VARIABLES LIKE 'gtid_binlog_pos';
Variable_name Value
......
......@@ -12,6 +12,8 @@ connection server_2;
SET GLOBAL gtid_slave_pos="";
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
SELECT * FROM t1;
a
......@@ -34,6 +36,8 @@ connection server_2;
SET GLOBAL gtid_slave_pos="";
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
START SLAVE;
include/wait_for_slave_io_error.inc [errno=1236]
include/stop_slave.inc
......@@ -56,6 +60,8 @@ connection server_2;
SET GLOBAL gtid_slave_pos='0-1-3';
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER by a;
......@@ -98,6 +104,8 @@ RESET MASTER;
connection server_2;
SET GLOBAL gtid_slave_pos='';
CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
connection server_1;
CREATE TABLE t1 (a INT PRIMARY KEY);
......@@ -155,6 +163,8 @@ START SLAVE;
include/wait_for_slave_sql_error.inc [errno=1050]
STOP SLAVE IO_THREAD;
CHANGE MASTER TO MASTER_USE_GTID=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
connection server_1;
INSERT INTO t1 VALUES(3);
......
......@@ -8,6 +8,8 @@ include/stop_slave.inc
Master_Log_File = 'master-bin.000001'
Using_Gtid = 'Slave_Pos'
CHANGE MASTER TO master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
FLUSH LOGS;
connection server_1;
FLUSH LOGS;
......
......@@ -30,6 +30,8 @@ include/stop_slave_io.inc
START SLAVE UNTIL master_gtid_pos = "";
ERROR HY000: START SLAVE UNTIL master_gtid_pos requires that slave is using GTID
CHANGE MASTER TO master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
connection server_1;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
......@@ -218,6 +220,8 @@ INSERT INTO t1 VALUES (10);
connection server_2;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_1,
master_user = "root", master_use_gtid = current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
START SLAVE UNTIL master_gtid_pos = '0-1-2';
include/wait_for_slave_to_start.inc
connection server_1;
......
......@@ -11,6 +11,8 @@ CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on w
INSERT INTO t1 VALUES (1, 2);
SET sql_log_bin= 1;
CHANGE MASTER TO master_use_gtid= current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
Contents on slave before:
SELECT * FROM t1 ORDER BY a;
a b
......
......@@ -5,6 +5,8 @@ SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
include/stop_slave.inc
SET GLOBAL slave_parallel_threads=10;
CHANGE MASTER TO master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
*** MDEV-6589: Incorrect relay log start position when restarting SQL thread after error in parallel replication ***
connection server_1;
......
......@@ -18,11 +18,15 @@ SET @old_updates= @@GLOBAL.binlog_direct_non_transactional_updates;
SET GLOBAL binlog_direct_non_transactional_updates=OFF;
SET SESSION binlog_direct_non_transactional_updates=OFF;
CHANGE MASTER TO master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
connection server_3;
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
include/stop_slave.inc
SET GLOBAL slave_parallel_threads=10;
CHANGE MASTER TO master_use_gtid=current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
connection server_1;
BEGIN;
CREATE TEMPORARY TABLE t2 (a INT PRIMARY KEY) ENGINE=MEMORY;
......
......@@ -5,6 +5,8 @@ SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
include/stop_slave.inc
SET GLOBAL slave_parallel_threads=5;
CHANGE MASTER TO master_use_gtid= current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
connection server_1;
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(100) CHARACTER SET utf8);
......
......@@ -87,6 +87,8 @@ include/assert.inc [Value returned by SSS and PS table for Using_Gtid should be
change master to
master_user = 'root',
master_use_gtid= CURRENT_POS;
Warnings:
Warning #### 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/assert.inc [Value returned by SSS and PS table for Using_Gtid should be same.]
# 3) Test for Auto_position= SLAVE_POS
......
......@@ -5,6 +5,8 @@ set global binlog_alter_two_phase=true;
connection slave;
include/stop_slave.inc
change master to master_use_gtid= current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
set global gtid_strict_mode=1;
# Legacy Master Slave
connect master_node,127.0.0.1,root,,$db_name, $M_port;
......
......@@ -3,6 +3,8 @@ include/master-slave.inc
connection slave;
stop slave;
change master to master_use_gtid= current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
SET GLOBAL slave_parallel_threads=4;
set global slave_parallel_mode=optimistic;
set global gtid_strict_mode=1;
......@@ -94,6 +96,8 @@ include/start_slave.inc
connection slave;
stop slave;
change master to master_use_gtid= current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
SET GLOBAL slave_parallel_threads=4;
set global slave_parallel_mode=optimistic;
set global gtid_strict_mode=1;
......@@ -185,6 +189,8 @@ include/start_slave.inc
connection slave;
stop slave;
change master to master_use_gtid= current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
SET GLOBAL slave_parallel_threads=4;
set global slave_parallel_mode=optimistic;
set global gtid_strict_mode=1;
......@@ -315,6 +321,8 @@ include/start_slave.inc
connection slave;
stop slave;
change master to master_use_gtid= current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
SET GLOBAL slave_parallel_threads=4;
set global slave_parallel_mode=optimistic;
set global gtid_strict_mode=1;
......@@ -406,6 +414,8 @@ include/start_slave.inc
connection slave;
stop slave;
change master to master_use_gtid= current_pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
SET GLOBAL slave_parallel_threads=4;
set global slave_parallel_mode=optimistic;
set global gtid_strict_mode=1;
......
......@@ -4,6 +4,8 @@ include/master-slave.inc
connection slave;
include/stop_slave.inc
CHANGE MASTER TO master_use_gtid=CURRENT_POS;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/rpl_stop_server.inc [server_number=2]
include/rpl_start_server.inc [server_number=2]
connection master;
......
......@@ -58,6 +58,8 @@ include/start_slave.inc
# to its default of Slave_Pos after RESET SLAVE.
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=Current_Pos;
Warnings:
Warning 1681 'master_use_gtid=current_pos' is deprecated and will be removed in a future release. Please use master_demote_to_slave=1 instead
include/start_slave.inc
include/stop_slave.inc
RESET SLAVE;
......
......@@ -108,4 +108,10 @@ CHANGE MASTER TO MASTER_USER='root', MASTER_SSL=0, MASTER_SSL_CA='', MASTER_SSL_
MASTER_SSL_KEY='', MASTER_SSL_CRL='', MASTER_SSL_CRLPATH='';
CHANGE MASTER TO MASTER_USER='root', MASTER_PASSWORD='', MASTER_SSL=0;
# MDEV-20122: Deprecate MASTER_USE_GTID=Current_Pos to favor new MASTER_DEMOTE_TO_SLAVE option
--echo "Usage of CURRENT_POS in CHANGE MASTER MASTER_USE_GTID is dreprecated.
CHANGE MASTER TO MASTER_USE_GTID=CURRENT_POS;
CHANGE MASTER TO MASTER_USE_GTID=SLAVE_POS;
--source include/rpl_end.inc
This diff is collapsed.
......@@ -385,6 +385,7 @@ SYMBOL symbols[] = {
{ "MASTER_SSL_VERIFY_SERVER_CERT", SYM(MASTER_SSL_VERIFY_SERVER_CERT_SYM)},
{ "MASTER_USER", SYM(MASTER_USER_SYM)},
{ "MASTER_USE_GTID", SYM(MASTER_USE_GTID_SYM)},
{ "MASTER_DEMOTE_TO_SLAVE", SYM(MASTER_DEMOTE_TO_SLAVE_SYM)},
{ "MASTER_HEARTBEAT_PERIOD", SYM(MASTER_HEARTBEAT_PERIOD_SYM)},
{ "MATCH", SYM(MATCH)},
{ "MAX_CONNECTIONS_PER_HOUR", SYM(MAX_CONNECTIONS_PER_HOUR)},
......
......@@ -368,6 +368,14 @@ class Master_info : public Slave_reporting_capability
Cache the value so future RESET SLAVE commands don't revert to Slave_Pos.
*/
bool master_supports_gtid;
/*
When TRUE, transition this server from being an active master to a slave.
This updates the replication state to account for any transactions which
were committed into the binary log. In particular, it merges
gtid_binlog_pos into gtid_slave_pos.
*/
bool is_demotion;
};
struct start_alter_thd_args
......
......@@ -498,6 +498,7 @@ struct LEX_MASTER_INFO
uint port, connect_retry;
float heartbeat_period;
int sql_delay;
bool is_demotion_opt;
/*
Enum is used for making it possible to detect if the user
changed variable or if it should be left at old value
......@@ -540,6 +541,7 @@ struct LEX_MASTER_INFO
gtid_pos_str= null_clex_str;
use_gtid_opt= LEX_GTID_UNCHANGED;
sql_delay= -1;
is_demotion_opt= 0;
}
};
......
......@@ -3822,7 +3822,13 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
if (lex_mi->use_gtid_opt == LEX_MASTER_INFO::LEX_GTID_SLAVE_POS)
mi->using_gtid= Master_info::USE_GTID_SLAVE_POS;
else if (lex_mi->use_gtid_opt == LEX_MASTER_INFO::LEX_GTID_CURRENT_POS)
{
mi->using_gtid= Master_info::USE_GTID_CURRENT_POS;
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
ER_THD(thd, ER_WARN_DEPRECATED_SYNTAX),
"master_use_gtid=current_pos", "master_demote_to_slave=1");
}
else if (lex_mi->use_gtid_opt == LEX_MASTER_INFO::LEX_GTID_NO ||
lex_mi->log_file_name || lex_mi->pos ||
lex_mi->relay_log_name || lex_mi->relay_log_pos)
......@@ -3913,6 +3919,40 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
strmake_buf(mi->master_log_name, mi->rli.group_master_log_name);
}
/*
MASTER_DEMOTE_TO_SLAVE is set. Merge gtid_binlog_pos into gtid_slave_pos.
*/
if (lex_mi->is_demotion_opt)
{
String new_gtid_state;
if (mi->using_gtid != Master_info::USE_GTID_SLAVE_POS)
{
my_error(ER_CM_OPTION_MISSING_REQUIREMENT, MYF(0),
"MASTER_DEMOTE_TO_SLAVE", "TRUE", "Using_Gtid=Slave_Pos");
ret= TRUE;
goto err;
}
if (!mysql_bin_log.is_open())
{
my_error(ER_NO_BINARY_LOGGING, MYF(0));
ret= TRUE;
goto err;
}
if ((ret= rpl_append_gtid_state(&new_gtid_state, true)))
goto err;
if (rpl_global_gtid_slave_state->load(
thd, new_gtid_state.ptr(), new_gtid_state.length(), true, true))
{
my_error(ER_FAILED_GTID_STATE_INIT, MYF(0));
ret= TRUE;
goto err;
}
}
/*
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
a slave before).
......
......@@ -936,6 +936,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token <kwd> MASTER_USER_SYM
%token <kwd> MASTER_USE_GTID_SYM
%token <kwd> MASTER_HEARTBEAT_PERIOD_SYM
%token <kwd> MASTER_DEMOTE_TO_SLAVE_SYM
%token <kwd> MAX_CONNECTIONS_PER_HOUR
%token <kwd> MAX_QUERIES_PER_HOUR
%token <kwd> MAX_ROWS
......@@ -2292,6 +2293,10 @@ master_file_def:
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MASTER_use_gtid"));
Lex->mi.use_gtid_opt= LEX_MASTER_INFO::LEX_GTID_NO;
}
| MASTER_DEMOTE_TO_SLAVE_SYM '=' bool
{
Lex->mi.is_demotion_opt= (bool) $3;
}
;
optional_connection_name:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment