mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
MDEV-20601: Make REPLICA a synonym for SLAVE in SQL statements
Fix: === Add "REPLICA" as an alias for "SLAVE". All commands which use "SLAVE" keyword can be used with new alias "REPLICA". List of commands: On Master: ========= SHOW REPLICA HOSTS <--> SHOW SLAVE HOSTS Privilege "SLAVE" <--> "REPLICA" On Slave: ========= START SLAVE <--> START REPLICA START ALL SLAVES <--> START ALL REPLICAS START SLAVE UNTIL <--> START REPLICA UNTIL STOP SLAVE <--> STOP REPLICA STOP ALL SLAVES <--> STOP ALL REPLICAS RESET SLAVE <--> RESET REPLICA RESET SLAVE ALL <--> RESET REPLICA ALL SLAVE_POS <--> REPLICA_POS
This commit is contained in:
parent
287c1db786
commit
42e825dd0a
5 changed files with 392 additions and 0 deletions
|
@ -0,0 +1,157 @@
|
|||
connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3;
|
||||
connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1;
|
||||
connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2;
|
||||
connection slave;
|
||||
CHANGE MASTER 'slave1' TO MASTER_PORT=MYPORT_1, MASTER_HOST='127.0.0.1', MASTER_USER='root';
|
||||
CHANGE MASTER 'slave2' TO MASTER_PORT=MYPORT_2, MASTER_HOST='127.0.0.1', MASTER_USER='root';
|
||||
START REPLICA 'slave1';
|
||||
SET default_master_connection = 'slave1';
|
||||
include/wait_for_slave_to_start.inc
|
||||
SET default_master_connection = 'slave2';
|
||||
"Command: START ALL SLAVES --> START ALL REPLICAS"
|
||||
START ALL REPLICAS;
|
||||
Warnings:
|
||||
Note 1937 SLAVE 'slave2' started
|
||||
include/wait_for_slave_to_start.inc
|
||||
SET default_master_connection = '';
|
||||
connection master1;
|
||||
connection slave;
|
||||
connection master2;
|
||||
connection slave;
|
||||
"Command: SHOW ALL STAVES STATUS --> SHOW ALL REPLICAS STATUS"
|
||||
SHOW ALL REPLICAS STATUS;
|
||||
Connection_name slave1
|
||||
Slave_SQL_State Slave has read all relay log; waiting for the slave I/O thread to update it
|
||||
Slave_IO_State Waiting for master to send event
|
||||
Master_Host 127.0.0.1
|
||||
Master_User root
|
||||
Master_Port MYPORT_1
|
||||
Connect_Retry 60
|
||||
Master_Log_File master-bin.000001
|
||||
Read_Master_Log_Pos <read_master_log_pos>
|
||||
Relay_Log_File mysqld-relay-bin-slave1.000002
|
||||
Relay_Log_Pos <relay_log_pos>
|
||||
Relay_Master_Log_File master-bin.000001
|
||||
Slave_IO_Running Yes
|
||||
Slave_SQL_Running Yes
|
||||
Replicate_Do_DB
|
||||
Replicate_Ignore_DB
|
||||
Replicate_Do_Table
|
||||
Replicate_Ignore_Table
|
||||
Replicate_Wild_Do_Table
|
||||
Replicate_Wild_Ignore_Table
|
||||
Last_Errno 0
|
||||
Last_Error
|
||||
Skip_Counter 0
|
||||
Exec_Master_Log_Pos <read_master_log_pos>
|
||||
Relay_Log_Space <relay_log_space1>
|
||||
Until_Condition None
|
||||
Until_Log_File
|
||||
Until_Log_Pos 0
|
||||
Master_SSL_Allowed No
|
||||
Master_SSL_CA_File
|
||||
Master_SSL_CA_Path
|
||||
Master_SSL_Cert
|
||||
Master_SSL_Cipher
|
||||
Master_SSL_Key
|
||||
Seconds_Behind_Master 0
|
||||
Master_SSL_Verify_Server_Cert No
|
||||
Last_IO_Errno 0
|
||||
Last_IO_Error
|
||||
Last_SQL_Errno 0
|
||||
Last_SQL_Error
|
||||
Replicate_Ignore_Server_Ids
|
||||
Master_Server_Id 1
|
||||
Master_SSL_Crl
|
||||
Master_SSL_Crlpath
|
||||
Using_Gtid No
|
||||
Gtid_IO_Pos
|
||||
Replicate_Do_Domain_Ids
|
||||
Replicate_Ignore_Domain_Ids
|
||||
Parallel_Mode optimistic
|
||||
SQL_Delay 0
|
||||
SQL_Remaining_Delay NULL
|
||||
Slave_SQL_Running_State Slave has read all relay log; waiting for the slave I/O thread to update it
|
||||
Slave_DDL_Groups 0
|
||||
Slave_Non_Transactional_Groups 0
|
||||
Slave_Transactional_Groups 0
|
||||
Retried_transactions 0
|
||||
Max_relay_log_size 1073741824
|
||||
Executed_log_entries 7
|
||||
Slave_received_heartbeats 0
|
||||
Slave_heartbeat_period 60.000
|
||||
Gtid_Slave_Pos
|
||||
Connection_name slave2
|
||||
Slave_SQL_State Slave has read all relay log; waiting for the slave I/O thread to update it
|
||||
Slave_IO_State Waiting for master to send event
|
||||
Master_Host 127.0.0.1
|
||||
Master_User root
|
||||
Master_Port MYPORT_2
|
||||
Connect_Retry 60
|
||||
Master_Log_File master-bin.000001
|
||||
Read_Master_Log_Pos <read_master_log_pos>
|
||||
Relay_Log_File mysqld-relay-bin-slave2.000002
|
||||
Relay_Log_Pos <relay_log_pos>
|
||||
Relay_Master_Log_File master-bin.000001
|
||||
Slave_IO_Running Yes
|
||||
Slave_SQL_Running Yes
|
||||
Replicate_Do_DB
|
||||
Replicate_Ignore_DB
|
||||
Replicate_Do_Table
|
||||
Replicate_Ignore_Table
|
||||
Replicate_Wild_Do_Table
|
||||
Replicate_Wild_Ignore_Table
|
||||
Last_Errno 0
|
||||
Last_Error
|
||||
Skip_Counter 0
|
||||
Exec_Master_Log_Pos <read_master_log_pos>
|
||||
Relay_Log_Space <relay_log_space1>
|
||||
Until_Condition None
|
||||
Until_Log_File
|
||||
Until_Log_Pos 0
|
||||
Master_SSL_Allowed No
|
||||
Master_SSL_CA_File
|
||||
Master_SSL_CA_Path
|
||||
Master_SSL_Cert
|
||||
Master_SSL_Cipher
|
||||
Master_SSL_Key
|
||||
Seconds_Behind_Master 0
|
||||
Master_SSL_Verify_Server_Cert No
|
||||
Last_IO_Errno 0
|
||||
Last_IO_Error
|
||||
Last_SQL_Errno 0
|
||||
Last_SQL_Error
|
||||
Replicate_Ignore_Server_Ids
|
||||
Master_Server_Id 2
|
||||
Master_SSL_Crl
|
||||
Master_SSL_Crlpath
|
||||
Using_Gtid No
|
||||
Gtid_IO_Pos
|
||||
Replicate_Do_Domain_Ids
|
||||
Replicate_Ignore_Domain_Ids
|
||||
Parallel_Mode optimistic
|
||||
SQL_Delay 0
|
||||
SQL_Remaining_Delay NULL
|
||||
Slave_SQL_Running_State Slave has read all relay log; waiting for the slave I/O thread to update it
|
||||
Slave_DDL_Groups 0
|
||||
Slave_Non_Transactional_Groups 0
|
||||
Slave_Transactional_Groups 0
|
||||
Retried_transactions 0
|
||||
Max_relay_log_size 1073741824
|
||||
Executed_log_entries 7
|
||||
Slave_received_heartbeats 0
|
||||
Slave_heartbeat_period 60.000
|
||||
Gtid_Slave_Pos
|
||||
"Command: STOP ALL SLAVES --> STOP ALL REPLICAS"
|
||||
STOP ALL REPLICAS;
|
||||
Warnings:
|
||||
Note 1938 SLAVE 'slave2' stopped
|
||||
Note 1938 SLAVE 'slave1' stopped
|
||||
include/reset_master_slave.inc
|
||||
disconnect slave;
|
||||
connection master1;
|
||||
include/reset_master_slave.inc
|
||||
disconnect master1;
|
||||
connection master2;
|
||||
include/reset_master_slave.inc
|
||||
disconnect master2;
|
|
@ -0,0 +1,80 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Test verifies that SQL statements which use keyword 'REPLICA' a synonym for
|
||||
# 'SLAVE' work as expected.
|
||||
#
|
||||
# ==== Implementation ====
|
||||
#
|
||||
# List of commands being verified are
|
||||
#
|
||||
# START ALL REPLICAS
|
||||
# STOP ALL REPLICAS
|
||||
# SHOW ALL REPLICAS STATUS
|
||||
#
|
||||
# ==== References ====
|
||||
#
|
||||
# MDEV-20601: Make REPLICA a synonym for SLAVE in SQL statements
|
||||
#
|
||||
|
||||
--source include/not_embedded.inc
|
||||
--source include/binlog_start_pos.inc
|
||||
--let $rpl_server_count= 0
|
||||
|
||||
--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
|
||||
--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1)
|
||||
--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2)
|
||||
|
||||
--connection slave
|
||||
--replace_result $SERVER_MYPORT_1 MYPORT_1
|
||||
eval CHANGE MASTER 'slave1' TO MASTER_PORT=$SERVER_MYPORT_1, MASTER_HOST='127.0.0.1', MASTER_USER='root';
|
||||
--replace_result $SERVER_MYPORT_2 MYPORT_2
|
||||
eval CHANGE MASTER 'slave2' TO MASTER_PORT=$SERVER_MYPORT_2, MASTER_HOST='127.0.0.1', MASTER_USER='root';
|
||||
START REPLICA 'slave1';
|
||||
SET default_master_connection = 'slave1';
|
||||
--source include/wait_for_slave_to_start.inc
|
||||
SET default_master_connection = 'slave2';
|
||||
--echo "Command: START ALL SLAVES --> START ALL REPLICAS"
|
||||
START ALL REPLICAS;
|
||||
|
||||
--source include/wait_for_slave_to_start.inc
|
||||
SET default_master_connection = '';
|
||||
|
||||
# Ensure that all data is in the relay log
|
||||
--connection master1
|
||||
--save_master_pos
|
||||
--connection slave
|
||||
--sync_with_master 0,'slave1'
|
||||
--connection master2
|
||||
--save_master_pos
|
||||
--connection slave
|
||||
--sync_with_master 0,'slave2'
|
||||
|
||||
--echo "Command: SHOW ALL STAVES STATUS --> SHOW ALL REPLICAS STATUS"
|
||||
let $show_statement = SHOW ALL REPLICAS STATUS;
|
||||
let $field = Executed_log_entries;
|
||||
let $condition = = 7;
|
||||
let $wait_for_all = 1;
|
||||
--source include/wait_show_condition.inc
|
||||
|
||||
let read_master_log_pos=`select $binlog_start_pos + 73`;
|
||||
let relay_log_pos=`select 2*$binlog_start_pos + 117`;
|
||||
let relay_log_space1=`select 3*$binlog_start_pos + 178`;
|
||||
let relay_log_space2=`select 3*$binlog_start_pos + 178`;
|
||||
--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2>
|
||||
--query_vertical SHOW ALL REPLICAS STATUS
|
||||
|
||||
--echo "Command: STOP ALL SLAVES --> STOP ALL REPLICAS"
|
||||
STOP ALL REPLICAS;
|
||||
|
||||
#
|
||||
# clean up
|
||||
#
|
||||
|
||||
--source include/reset_master_slave.inc
|
||||
--disconnect slave
|
||||
--connection master1
|
||||
--source include/reset_master_slave.inc
|
||||
--disconnect master1
|
||||
--connection master2
|
||||
--source include/reset_master_slave.inc
|
||||
--disconnect master2
|
56
mysql-test/suite/rpl/r/rpl_slave_alias_replica.result
Normal file
56
mysql-test/suite/rpl/r/rpl_slave_alias_replica.result
Normal file
|
@ -0,0 +1,56 @@
|
|||
include/master-slave.inc
|
||||
[connection master]
|
||||
"Command: STOP SLAVE --> STOP REPLICA"
|
||||
connection slave;
|
||||
STOP REPLICA;
|
||||
include/wait_for_slave_io_to_stop.inc
|
||||
include/wait_for_slave_sql_to_stop.inc
|
||||
connection master;
|
||||
CREATE USER 'repl_user';
|
||||
"Privilege: SLAVE --> REPLICA"
|
||||
GRANT REPLICATION REPLICA on *.* TO repl_user;
|
||||
FLUSH PRIVILEGES;
|
||||
connection slave;
|
||||
"SHOW SLAVE STATUS --> SHOW REPLICA STATUS"
|
||||
CHANGE MASTER TO MASTER_USER= 'repl_user';
|
||||
"Command: START SLAVE --> START REPLICA"
|
||||
START REPLICA;
|
||||
include/wait_for_slave_io_to_start.inc
|
||||
include/wait_for_slave_sql_to_start.inc
|
||||
connection master;
|
||||
"Command: SHOW SLAVE HOSTS --> SHOW REPLICA HOSTS"
|
||||
SHOW REPLICA HOSTS;
|
||||
Server_id Host Port Master_id
|
||||
2 127.0.0.1 SLAVE_PORT 1
|
||||
DROP USER 'repl_user';
|
||||
connection slave;
|
||||
"Command: SHOW SLAVE IO/SQL THREAD --> SHOW REPLICA IO/SQL THREAD"
|
||||
STOP REPLICA IO_THREAD;
|
||||
STOP REPLICA SQL_THREAD;
|
||||
include/wait_for_slave_io_to_stop.inc
|
||||
include/wait_for_slave_sql_to_stop.inc
|
||||
"Command: RESET SLAVE ALL --> RESET REPLICA ALL"
|
||||
RESET REPLICA ALL;
|
||||
connection master;
|
||||
RESET MASTER;
|
||||
CREATE TABLE t(f INT) ENGINE=INNODB;
|
||||
INSERT INTO t VALUES (10);
|
||||
DROP TABLE t;
|
||||
connection slave;
|
||||
CHANGE MASTER TO MASTER_HOST='127.0.0.1',MASTER_PORT=MASTER_PORT,MASTER_USER='root';
|
||||
"Command: START SLAVE UNTIL --> START REPLICA UNTIL"
|
||||
START REPLICA UNTIL MASTER_LOG_FILE='MASTER_LOG_FILE', MASTER_LOG_POS=MASTER_POS;
|
||||
include/wait_for_slave_sql_to_stop.inc
|
||||
include/stop_slave_io.inc
|
||||
SELECT * FROM t;
|
||||
f
|
||||
10
|
||||
include/check_slave_param.inc [Exec_Master_Log_Pos]
|
||||
"MASTER_USE_GTID=SLAVE_POS --> MASTER_USE_GTID=REPLICA_POS"
|
||||
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT, MASTER_USE_GTID=REPLICA_POS;
|
||||
include/start_slave.inc
|
||||
connection master;
|
||||
CREATE TABLE t2 (f INT PRIMARY KEY) ENGINE=INNODB;
|
||||
INSERT INTO t2 VALUES (10);
|
||||
DROP TABLE t2;
|
||||
include/rpl_end.inc
|
96
mysql-test/suite/rpl/t/rpl_slave_alias_replica.test
Normal file
96
mysql-test/suite/rpl/t/rpl_slave_alias_replica.test
Normal file
|
@ -0,0 +1,96 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Test verifies that SQL statements which use keyword 'REPLICA' a synonym for
|
||||
# 'SLAVE' work as expected.
|
||||
#
|
||||
# ==== Implementation ====
|
||||
#
|
||||
# List of commands being verified are
|
||||
# On Master: SHOW REPLICA HOSTS
|
||||
# : Privilege "REPLICA"
|
||||
#
|
||||
# On Slave: START REPLICA
|
||||
# START REPLICA UNTIL
|
||||
# STOP REPLICA
|
||||
# SHOW REPLICA STATUS
|
||||
# RESET REPLICA ALL
|
||||
# REPLICA_POS
|
||||
#
|
||||
# ==== References ====
|
||||
#
|
||||
# MDEV-20601: Make REPLICA a synonym for SLAVE in SQL statements
|
||||
#
|
||||
|
||||
--source include/have_innodb.inc
|
||||
--source include/master-slave.inc
|
||||
|
||||
--echo "Command: STOP SLAVE --> STOP REPLICA"
|
||||
--connection slave
|
||||
STOP REPLICA;
|
||||
--source include/wait_for_slave_io_to_stop.inc
|
||||
--source include/wait_for_slave_sql_to_stop.inc
|
||||
|
||||
--connection master
|
||||
CREATE USER 'repl_user';
|
||||
--echo "Privilege: SLAVE --> REPLICA"
|
||||
GRANT REPLICATION REPLICA on *.* TO repl_user;
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
--connection slave
|
||||
--echo "SHOW SLAVE STATUS --> SHOW REPLICA STATUS"
|
||||
--let $master_user= query_get_value(SHOW REPLICA STATUS, Master_User, 1)
|
||||
CHANGE MASTER TO MASTER_USER= 'repl_user';
|
||||
--echo "Command: START SLAVE --> START REPLICA"
|
||||
START REPLICA;
|
||||
--source include/wait_for_slave_io_to_start.inc
|
||||
--source include/wait_for_slave_sql_to_start.inc
|
||||
|
||||
--connection master
|
||||
--echo "Command: SHOW SLAVE HOSTS --> SHOW REPLICA HOSTS"
|
||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||
SHOW REPLICA HOSTS;
|
||||
DROP USER 'repl_user';
|
||||
--sync_slave_with_master
|
||||
|
||||
--echo "Command: SHOW SLAVE IO/SQL THREAD --> SHOW REPLICA IO/SQL THREAD"
|
||||
STOP REPLICA IO_THREAD;
|
||||
STOP REPLICA SQL_THREAD;
|
||||
--source include/wait_for_slave_io_to_stop.inc
|
||||
--source include/wait_for_slave_sql_to_stop.inc
|
||||
--echo "Command: RESET SLAVE ALL --> RESET REPLICA ALL"
|
||||
RESET REPLICA ALL;
|
||||
|
||||
--connection master
|
||||
RESET MASTER;
|
||||
CREATE TABLE t(f INT) ENGINE=INNODB;
|
||||
INSERT INTO t VALUES (10);
|
||||
let $master_log_file= query_get_value(SHOW MASTER STATUS, File, 1);
|
||||
let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
DROP TABLE t;
|
||||
|
||||
--connection slave
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO MASTER_HOST='127.0.0.1',MASTER_PORT=$MASTER_MYPORT,MASTER_USER='$master_user';
|
||||
--echo "Command: START SLAVE UNTIL --> START REPLICA UNTIL"
|
||||
--replace_result $master_log_file MASTER_LOG_FILE $master_pos MASTER_POS
|
||||
--eval START REPLICA UNTIL MASTER_LOG_FILE='$master_log_file', MASTER_LOG_POS=$master_pos
|
||||
--source include/wait_for_slave_sql_to_stop.inc
|
||||
--source include/stop_slave_io.inc
|
||||
|
||||
SELECT * FROM t;
|
||||
--let $slave_param= Exec_Master_Log_Pos
|
||||
--let $slave_param_value= $master_pos
|
||||
--source include/check_slave_param.inc
|
||||
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
--echo "MASTER_USE_GTID=SLAVE_POS --> MASTER_USE_GTID=REPLICA_POS"
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
--eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT, MASTER_USE_GTID=REPLICA_POS
|
||||
--source include/start_slave.inc
|
||||
|
||||
--connection master
|
||||
CREATE TABLE t2 (f INT PRIMARY KEY) ENGINE=INNODB;
|
||||
INSERT INTO t2 VALUES (10);
|
||||
DROP TABLE t2;
|
||||
|
||||
--source include/rpl_end.inc
|
|
@ -520,6 +520,9 @@ static SYMBOL symbols[] = {
|
|||
{ "REPAIR", SYM(REPAIR)},
|
||||
{ "REPEATABLE", SYM(REPEATABLE_SYM)},
|
||||
{ "REPLACE", SYM(REPLACE)},
|
||||
{ "REPLICA", SYM(SLAVE)},
|
||||
{ "REPLICAS", SYM(SLAVES)},
|
||||
{ "REPLICA_POS", SYM(SLAVE_POS_SYM)},
|
||||
{ "REPLICATION", SYM(REPLICATION)},
|
||||
{ "REPEAT", SYM(REPEAT_SYM)},
|
||||
{ "REQUIRE", SYM(REQUIRE_SYM)},
|
||||
|
|
Loading…
Reference in a new issue