mirror of
https://github.com/MariaDB/server.git
synced 2025-11-10 23:02:54 +03:00
This commit makes replicas crash-safe by default by changing the Using_Gtid value to be Slave_Pos on a fresh slave start and after RESET SLAVE is issued. If the primary server does not support GTIDs (i.e., version < 10), the replica will fall back to Using_Gtid=No on slave start and after RESET SLAVE. The following additional informational messages/warnings are added: 1. When Using_Gtid is automatically changed. That is, if RESET SLAVE reverts Using_Gtid back to Slave_Pos, or Using_Gtid is inferred to No from a CHANGE MASTER TO given with log coordinates without MASTER_USE_GTID. 2. If options are ignored in CHANGE MASTER TO. If CHANGE MASTER TO is given with log coordinates, yet also specifies MASTER_USE_GTID=Slave_Pos, a warning message is given that the log coordinate options are ignored. Additionally, an MTR macro has been added for RESET SLAVE, reset_slave.inc, which provides modes/options for resetting a slave in log coordinate or gtid modes. When in log coordinates mode, the macro will execute CHANGE MASTER TO MASTER_USE_GTID=No after the RESET SLAVE command. When in GTID mode, an extra parameter, reset_slave_keep_gtid_state, can be set to reset or preserve the value of gtid_slave_pos. Reviewed By: =========== Andrei Elkin <andrei.elkin@mariadb.com>
161 lines
4.9 KiB
Plaintext
161 lines
4.9 KiB
Plaintext
#
|
|
# TODO: write here what the test checks after MDEV-11288 is fixed
|
|
#
|
|
# The test starts with unencrypted master.
|
|
# It stops replication, generates a few statement and row events
|
|
# on the master, then restarts the server with encrypted binlog,
|
|
# generates some more events and restarts it back without encryption
|
|
# (no encryption plugin).
|
|
# Then it resumes replication and checks what happens when the server
|
|
# tries to feed the binary logs (included the encrypted ones)
|
|
# to the slave.
|
|
#
|
|
|
|
--source include/have_binlog_format_mixed.inc
|
|
|
|
--echo #################
|
|
--echo # Initialization
|
|
--echo #################
|
|
|
|
--let $rpl_topology= 1->2
|
|
--source include/rpl_init.inc
|
|
|
|
--connection server_2
|
|
--source include/stop_slave.inc
|
|
CHANGE MASTER TO MASTER_USE_GTID=NO;
|
|
--source include/start_slave.inc
|
|
|
|
--connection server_1
|
|
|
|
--enable_connect_log
|
|
|
|
# We stop replication because we want it to happen after the switch
|
|
|
|
--connection server_2
|
|
--disable_connect_log
|
|
--source include/stop_slave.inc
|
|
--enable_connect_log
|
|
|
|
--echo #####################################################
|
|
--echo # Part 1: unencrypted master
|
|
--echo #####################################################
|
|
|
|
--connection server_1
|
|
|
|
call mtr.add_suppression("Got fatal error 1236 from master when reading data from binary log: 'Could not decrypt binlog: encryption key error;");
|
|
|
|
CREATE TABLE table1_no_encryption (
|
|
pk INT AUTO_INCREMENT PRIMARY KEY,
|
|
ts TIMESTAMP NULL,
|
|
b BLOB
|
|
) ENGINE=MyISAM;
|
|
|
|
INSERT INTO table1_no_encryption VALUES (NULL,NOW(),'data_no_encryption');
|
|
INSERT INTO table1_no_encryption SELECT NULL,NOW(),b FROM table1_no_encryption;
|
|
FLUSH BINARY LOGS;
|
|
SET binlog_format=ROW;
|
|
INSERT INTO table1_no_encryption SELECT NULL,NOW(),b FROM table1_no_encryption;
|
|
INSERT INTO table1_no_encryption SELECT NULL,NOW(),b FROM table1_no_encryption;
|
|
|
|
# Make sure that binary logs are not encrypted
|
|
|
|
--let SEARCH_RANGE = 500000
|
|
--let SEARCH_FILE= master-bin.0*
|
|
--let SEARCH_PATTERN= table1_no_encryption
|
|
--source include/search_pattern_in_file.inc
|
|
|
|
# We are storing the position now, because up to this point the slave
|
|
# should be able to synchronize with master
|
|
--save_master_pos
|
|
|
|
--echo #####################################################
|
|
--echo # Part 2: restart master, now with binlog encryption
|
|
--echo #####################################################
|
|
|
|
--let $rpl_server_parameters= --encrypt-binlog=1 --plugin-load-add=file_key_management --file-key-management --loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys.txt
|
|
|
|
--let $rpl_server_number= 1
|
|
--source restart_server.inc
|
|
|
|
CREATE TABLE table2_to_encrypt (
|
|
pk INT AUTO_INCREMENT PRIMARY KEY,
|
|
ts TIMESTAMP NULL,
|
|
b BLOB
|
|
) ENGINE=MyISAM;
|
|
|
|
INSERT INTO table2_to_encrypt VALUES (NULL,NOW(),'data_to_encrypt');
|
|
INSERT INTO table2_to_encrypt SELECT NULL,NOW(),b FROM table2_to_encrypt;
|
|
FLUSH BINARY LOGS;
|
|
SET binlog_format=ROW;
|
|
INSERT INTO table2_to_encrypt SELECT NULL,NOW(),b FROM table2_to_encrypt;
|
|
INSERT INTO table2_to_encrypt SELECT NULL,NOW(),b FROM table2_to_encrypt;
|
|
|
|
# Make sure that binary logs are encrypted
|
|
|
|
--let SEARCH_FILE= master-bin.0*
|
|
--let SEARCH_PATTERN= table2_to_encrypt
|
|
--source include/search_pattern_in_file.inc
|
|
|
|
--echo #####################################################
|
|
--echo # Part 3: restart master again without encryption
|
|
--echo #####################################################
|
|
|
|
--let $rpl_server_parameters= --encrypt-binlog=0
|
|
--let $rpl_server_number= 1
|
|
--source restart_server.inc
|
|
|
|
CREATE TABLE table3_no_encryption (
|
|
pk INT AUTO_INCREMENT PRIMARY KEY,
|
|
ts TIMESTAMP NULL,
|
|
b BLOB
|
|
) ENGINE=MyISAM;
|
|
|
|
INSERT INTO table3_no_encryption VALUES (NULL,NOW(),'data_no_encryption');
|
|
INSERT INTO table3_no_encryption SELECT NULL,NOW(),b FROM table3_no_encryption;
|
|
INSERT INTO table3_no_encryption SELECT NULL,NOW(),b FROM table3_no_encryption;
|
|
|
|
--echo #####################################################
|
|
--echo # Check: resume replication and check how it goes
|
|
--echo #####################################################
|
|
|
|
--connection server_2
|
|
start slave;
|
|
# The slave should be able to synchronize with master up to
|
|
# the previously saved position (when the log was still unencrypted)
|
|
--sync_with_master
|
|
|
|
--connection server_1
|
|
# Now save the current position and make slave to try to syncrhonize.
|
|
# It shouldn't work, the slave IO thread is expected to abort with an error
|
|
--save_master_pos
|
|
|
|
--connection server_2
|
|
--let slave_io_errno=1236
|
|
--source include/wait_for_slave_io_error.inc
|
|
|
|
--sorted_result
|
|
SHOW TABLES;
|
|
|
|
--disable_connect_log
|
|
--source include/stop_slave.inc
|
|
--enable_connect_log
|
|
--let $master_use_gtid_option= No
|
|
--source include/reset_slave.inc
|
|
|
|
--echo ##########
|
|
--echo # Cleanup
|
|
--echo ##########
|
|
|
|
--connection server_1
|
|
reset master;
|
|
|
|
SELECT COUNT(*) FROM table1_no_encryption;
|
|
SELECT COUNT(*) FROM table2_to_encrypt;
|
|
SELECT COUNT(*) FROM table3_no_encryption;
|
|
DROP TABLE table1_no_encryption, table2_to_encrypt, table3_no_encryption;
|
|
|
|
--connection server_2
|
|
--disable_connect_log
|
|
--source include/start_slave.inc
|
|
--source include/rpl_end.inc
|