2010-12-19 18:15:12 +01:00
|
|
|
--source include/master-slave.inc
|
BUG #8368 "mysqldump needs --slave-data option"
Added this option, named as "--dump-slave". The purpose of this option is to be
able to produce a dump from a slave used for making backups of the master. Originally,
dumping from the main master was fine, but as more data accumulated, the dump process
would take over 30 minutes, locking up the master database hence website for 30 minutes.
A slave dedicated to producing backups was the answer, but I needed a dump that could be
used to restore a slave instantly and in order to do that, it has to have three things
contained in the dump:
1. "STOP SLAVE;" at the beginning
2. "CHANGE MASTER TO ...<the master - info from 'show slave status'>"
3. "START SLAVE;" at the end
These options in this changeset contain this.
--stop-slave adds "STOP SLAVE" to the beginning of the dump and "STOP SLAVE"
to the end of the dump.
--include-host gives the user the option to have the host explicitely added
to the "CHANGE MASTER TO ..." line.
--dump-slave adds the "CHANGE MASTER ..." to the dump representing not the slave's
master binlog info, but the slave's master's info from "SHOW SLAVE STATUS"
client/client_priv.h:
Added OPT_SLAVE_DATA to client_priv.h
client/mysqldump.c:
* Added --dump-slave option (name per Brian)
* Added --stop-slave to print "STOP SLAVE;" into the dump
* Added --include-host option to include "MASTER_HOST=..." and "MASTER_PORT=..."
to the dump since unlike --master-data, the host can't be assumed to be
the local host
* Added do_start_slave and do_stop_slave to stop the slave sql thread upon
start of the dump process, and to start the slave sql upon finish of dump process -
to keep the log information frozen during this time.
* Added do_show_slave_status for obtaining slave information needed to compose
"CHANGE MASTER ..." output to the master of this slave.
* Added necessary long options and defines required for new options
2009-11-04 14:31:03 +01:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # New --dump-slave, --apply-slave-statements functionality
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
# There is a gap between when START SLAVE returns and when MASTER_LOG_FILE and
|
|
|
|
# MASTER_LOG_POS are set. Ensure that we don't call SHOW SLAVE STATUS during
|
|
|
|
# that gap.
|
|
|
|
--sync_slave_with_master
|
|
|
|
|
|
|
|
connection master;
|
|
|
|
use test;
|
|
|
|
|
|
|
|
connection slave;
|
|
|
|
|
|
|
|
# Execute mysqldump with --dump-slave
|
2010-07-16 20:25:00 +02:00
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
BUG #8368 "mysqldump needs --slave-data option"
Added this option, named as "--dump-slave". The purpose of this option is to be
able to produce a dump from a slave used for making backups of the master. Originally,
dumping from the main master was fine, but as more data accumulated, the dump process
would take over 30 minutes, locking up the master database hence website for 30 minutes.
A slave dedicated to producing backups was the answer, but I needed a dump that could be
used to restore a slave instantly and in order to do that, it has to have three things
contained in the dump:
1. "STOP SLAVE;" at the beginning
2. "CHANGE MASTER TO ...<the master - info from 'show slave status'>"
3. "START SLAVE;" at the end
These options in this changeset contain this.
--stop-slave adds "STOP SLAVE" to the beginning of the dump and "STOP SLAVE"
to the end of the dump.
--include-host gives the user the option to have the host explicitely added
to the "CHANGE MASTER TO ..." line.
--dump-slave adds the "CHANGE MASTER ..." to the dump representing not the slave's
master binlog info, but the slave's master's info from "SHOW SLAVE STATUS"
client/client_priv.h:
Added OPT_SLAVE_DATA to client_priv.h
client/mysqldump.c:
* Added --dump-slave option (name per Brian)
* Added --stop-slave to print "STOP SLAVE;" into the dump
* Added --include-host option to include "MASTER_HOST=..." and "MASTER_PORT=..."
to the dump since unlike --master-data, the host can't be assumed to be
the local host
* Added do_start_slave and do_stop_slave to stop the slave sql thread upon
start of the dump process, and to start the slave sql upon finish of dump process -
to keep the log information frozen during this time.
* Added do_show_slave_status for obtaining slave information needed to compose
"CHANGE MASTER ..." output to the master of this slave.
* Added necessary long options and defines required for new options
2009-11-04 14:31:03 +01:00
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave test
|
|
|
|
|
|
|
|
# Execute mysqldump with --dump-slave and --apply-slave-statements
|
2010-07-16 20:25:00 +02:00
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
BUG #8368 "mysqldump needs --slave-data option"
Added this option, named as "--dump-slave". The purpose of this option is to be
able to produce a dump from a slave used for making backups of the master. Originally,
dumping from the main master was fine, but as more data accumulated, the dump process
would take over 30 minutes, locking up the master database hence website for 30 minutes.
A slave dedicated to producing backups was the answer, but I needed a dump that could be
used to restore a slave instantly and in order to do that, it has to have three things
contained in the dump:
1. "STOP SLAVE;" at the beginning
2. "CHANGE MASTER TO ...<the master - info from 'show slave status'>"
3. "START SLAVE;" at the end
These options in this changeset contain this.
--stop-slave adds "STOP SLAVE" to the beginning of the dump and "STOP SLAVE"
to the end of the dump.
--include-host gives the user the option to have the host explicitely added
to the "CHANGE MASTER TO ..." line.
--dump-slave adds the "CHANGE MASTER ..." to the dump representing not the slave's
master binlog info, but the slave's master's info from "SHOW SLAVE STATUS"
client/client_priv.h:
Added OPT_SLAVE_DATA to client_priv.h
client/mysqldump.c:
* Added --dump-slave option (name per Brian)
* Added --stop-slave to print "STOP SLAVE;" into the dump
* Added --include-host option to include "MASTER_HOST=..." and "MASTER_PORT=..."
to the dump since unlike --master-data, the host can't be assumed to be
the local host
* Added do_start_slave and do_stop_slave to stop the slave sql thread upon
start of the dump process, and to start the slave sql upon finish of dump process -
to keep the log information frozen during this time.
* Added do_show_slave_status for obtaining slave information needed to compose
"CHANGE MASTER ..." output to the master of this slave.
* Added necessary long options and defines required for new options
2009-11-04 14:31:03 +01:00
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements test
|
|
|
|
|
2010-07-16 20:25:00 +02:00
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
BUG #8368 "mysqldump needs --slave-data option"
Added this option, named as "--dump-slave". The purpose of this option is to be
able to produce a dump from a slave used for making backups of the master. Originally,
dumping from the main master was fine, but as more data accumulated, the dump process
would take over 30 minutes, locking up the master database hence website for 30 minutes.
A slave dedicated to producing backups was the answer, but I needed a dump that could be
used to restore a slave instantly and in order to do that, it has to have three things
contained in the dump:
1. "STOP SLAVE;" at the beginning
2. "CHANGE MASTER TO ...<the master - info from 'show slave status'>"
3. "START SLAVE;" at the end
These options in this changeset contain this.
--stop-slave adds "STOP SLAVE" to the beginning of the dump and "STOP SLAVE"
to the end of the dump.
--include-host gives the user the option to have the host explicitely added
to the "CHANGE MASTER TO ..." line.
--dump-slave adds the "CHANGE MASTER ..." to the dump representing not the slave's
master binlog info, but the slave's master's info from "SHOW SLAVE STATUS"
client/client_priv.h:
Added OPT_SLAVE_DATA to client_priv.h
client/mysqldump.c:
* Added --dump-slave option (name per Brian)
* Added --stop-slave to print "STOP SLAVE;" into the dump
* Added --include-host option to include "MASTER_HOST=..." and "MASTER_PORT=..."
to the dump since unlike --master-data, the host can't be assumed to be
the local host
* Added do_start_slave and do_stop_slave to stop the slave sql thread upon
start of the dump process, and to start the slave sql upon finish of dump process -
to keep the log information frozen during this time.
* Added do_show_slave_status for obtaining slave information needed to compose
"CHANGE MASTER ..." output to the master of this slave.
* Added necessary long options and defines required for new options
2009-11-04 14:31:03 +01:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_MYPORT
|
|
|
|
# Execute mysqldump with --dump-slave ,--apply-slave-statements and --include-master-host-port
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements --include-master-host-port test
|
2010-12-19 18:15:12 +01:00
|
|
|
|
2014-02-21 00:53:02 +01:00
|
|
|
#
|
|
|
|
# MDEV-5624 mysqldump --dump-slave option does not restart the replication if the dump has failed
|
|
|
|
#
|
2014-02-26 15:28:07 +01:00
|
|
|
start slave;
|
2014-02-21 00:53:02 +01:00
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--error 2
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave no_such_db
|
2014-02-26 15:28:07 +01:00
|
|
|
start slave;
|
2014-02-21 00:53:02 +01:00
|
|
|
|
MDEV-6336: mysqldump --master-data does not work with GTID setups
MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated
Add a --gtid option (for compatibility, the original behaviour is preserved
when --gtid is not used).
With --gtid, --master-data and --dump-slave output the GTID position (the
old-style file/offset position is still output, but commented out). Also, a
CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned
slave is configured in GTID, as requested.
Without --gtid, the GTID position is still output, if available, but commented
out.
Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a
mysqldump on a slave server will silently inject a GTID which does not exist
on the master, which is highly undesirable.
Also fix an incorrect error handling around obtaining binlog position with
--master-data (was probably unlikely to trigger in most cases).
2014-07-09 13:36:28 +02:00
|
|
|
|
2024-02-06 08:20:53 +01:00
|
|
|
--echo *** Test mysqldump --dump-slave GTID/non-gtid functionality.
|
MDEV-6336: mysqldump --master-data does not work with GTID setups
MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated
Add a --gtid option (for compatibility, the original behaviour is preserved
when --gtid is not used).
With --gtid, --master-data and --dump-slave output the GTID position (the
old-style file/offset position is still output, but commented out). Also, a
CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned
slave is configured in GTID, as requested.
Without --gtid, the GTID position is still output, if available, but commented
out.
Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a
mysqldump on a slave server will silently inject a GTID which does not exist
on the master, which is highly undesirable.
Also fix an incorrect error handling around obtaining binlog position with
--master-data (was probably unlikely to trigger in most cases).
2014-07-09 13:36:28 +02:00
|
|
|
|
|
|
|
--connection master
|
|
|
|
SET gtid_seq_no = 1000;
|
|
|
|
CREATE TABLE t1 (a INT PRIMARY KEY);
|
|
|
|
DROP TABLE t1;
|
|
|
|
--sync_slave_with_master
|
|
|
|
|
|
|
|
--connection slave
|
|
|
|
# Inject a local transaction on the slave to check that this is not considered
|
|
|
|
# for --dump-slave.
|
|
|
|
CREATE TABLE t2 (a INT PRIMARY KEY);
|
|
|
|
DROP TABLE t2;
|
|
|
|
|
|
|
|
--echo
|
2024-02-06 08:20:53 +01:00
|
|
|
--echo 1. --dump-slave=1 --gtid
|
MDEV-6336: mysqldump --master-data does not work with GTID setups
MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated
Add a --gtid option (for compatibility, the original behaviour is preserved
when --gtid is not used).
With --gtid, --master-data and --dump-slave output the GTID position (the
old-style file/offset position is still output, but commented out). Also, a
CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned
slave is configured in GTID, as requested.
Without --gtid, the GTID position is still output, if available, but commented
out.
Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a
mysqldump on a slave server will silently inject a GTID which does not exist
on the master, which is highly undesirable.
Also fix an incorrect error handling around obtaining binlog position with
--master-data (was probably unlikely to trigger in most cases).
2014-07-09 13:36:28 +02:00
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=1 --gtid test
|
|
|
|
|
|
|
|
--echo
|
2024-02-06 08:20:53 +01:00
|
|
|
--echo 1a. --dump-slave=1
|
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=1 test
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo 2. --dump-slave=2 --gtid
|
MDEV-6336: mysqldump --master-data does not work with GTID setups
MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated
Add a --gtid option (for compatibility, the original behaviour is preserved
when --gtid is not used).
With --gtid, --master-data and --dump-slave output the GTID position (the
old-style file/offset position is still output, but commented out). Also, a
CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned
slave is configured in GTID, as requested.
Without --gtid, the GTID position is still output, if available, but commented
out.
Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a
mysqldump on a slave server will silently inject a GTID which does not exist
on the master, which is highly undesirable.
Also fix an incorrect error handling around obtaining binlog position with
--master-data (was probably unlikely to trigger in most cases).
2014-07-09 13:36:28 +02:00
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=2 --gtid test
|
|
|
|
|
2024-02-06 08:20:53 +01:00
|
|
|
--echo
|
|
|
|
--echo 2. --dump-slave=2
|
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=2 test
|
|
|
|
|
MDEV-6336: mysqldump --master-data does not work with GTID setups
MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated
Add a --gtid option (for compatibility, the original behaviour is preserved
when --gtid is not used).
With --gtid, --master-data and --dump-slave output the GTID position (the
old-style file/offset position is still output, but commented out). Also, a
CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned
slave is configured in GTID, as requested.
Without --gtid, the GTID position is still output, if available, but commented
out.
Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a
mysqldump on a slave server will silently inject a GTID which does not exist
on the master, which is highly undesirable.
Also fix an incorrect error handling around obtaining binlog position with
--master-data (was probably unlikely to trigger in most cases).
2014-07-09 13:36:28 +02:00
|
|
|
|
2024-02-06 08:20:53 +01:00
|
|
|
--echo *** Test mysqldump --master-data GTID/non-gtid functionality.
|
MDEV-6336: mysqldump --master-data does not work with GTID setups
MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated
Add a --gtid option (for compatibility, the original behaviour is preserved
when --gtid is not used).
With --gtid, --master-data and --dump-slave output the GTID position (the
old-style file/offset position is still output, but commented out). Also, a
CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned
slave is configured in GTID, as requested.
Without --gtid, the GTID position is still output, if available, but commented
out.
Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a
mysqldump on a slave server will silently inject a GTID which does not exist
on the master, which is highly undesirable.
Also fix an incorrect error handling around obtaining binlog position with
--master-data (was probably unlikely to trigger in most cases).
2014-07-09 13:36:28 +02:00
|
|
|
--echo
|
2024-02-06 08:20:53 +01:00
|
|
|
--echo 1. --master-data=1 --gtid
|
MDEV-6336: mysqldump --master-data does not work with GTID setups
MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated
Add a --gtid option (for compatibility, the original behaviour is preserved
when --gtid is not used).
With --gtid, --master-data and --dump-slave output the GTID position (the
old-style file/offset position is still output, but commented out). Also, a
CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned
slave is configured in GTID, as requested.
Without --gtid, the GTID position is still output, if available, but commented
out.
Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a
mysqldump on a slave server will silently inject a GTID which does not exist
on the master, which is highly undesirable.
Also fix an incorrect error handling around obtaining binlog position with
--master-data (was probably unlikely to trigger in most cases).
2014-07-09 13:36:28 +02:00
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --master-data=1 --gtid test
|
|
|
|
|
|
|
|
--echo
|
2024-02-06 08:20:53 +01:00
|
|
|
--echo 1a. --master-data=1
|
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --master-data=1 test
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo 2. --master-data=2 --gtid
|
MDEV-6336: mysqldump --master-data does not work with GTID setups
MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated
Add a --gtid option (for compatibility, the original behaviour is preserved
when --gtid is not used).
With --gtid, --master-data and --dump-slave output the GTID position (the
old-style file/offset position is still output, but commented out). Also, a
CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned
slave is configured in GTID, as requested.
Without --gtid, the GTID position is still output, if available, but commented
out.
Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a
mysqldump on a slave server will silently inject a GTID which does not exist
on the master, which is highly undesirable.
Also fix an incorrect error handling around obtaining binlog position with
--master-data (was probably unlikely to trigger in most cases).
2014-07-09 13:36:28 +02:00
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --master-data=2 --gtid test
|
|
|
|
|
|
|
|
--echo
|
2024-02-06 08:20:53 +01:00
|
|
|
--echo 2a. --master-data=2
|
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --master-data=2 test
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo 3. --master-data --single-transaction --gtid
|
MDEV-6336: mysqldump --master-data does not work with GTID setups
MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated
Add a --gtid option (for compatibility, the original behaviour is preserved
when --gtid is not used).
With --gtid, --master-data and --dump-slave output the GTID position (the
old-style file/offset position is still output, but commented out). Also, a
CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned
slave is configured in GTID, as requested.
Without --gtid, the GTID position is still output, if available, but commented
out.
Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a
mysqldump on a slave server will silently inject a GTID which does not exist
on the master, which is highly undesirable.
Also fix an incorrect error handling around obtaining binlog position with
--master-data (was probably unlikely to trigger in most cases).
2014-07-09 13:36:28 +02:00
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --master-data --single-transaction --gtid test
|
|
|
|
|
2024-02-06 08:20:53 +01:00
|
|
|
--echo
|
|
|
|
--echo 3a. --master-data --single-transaction
|
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --compact --master-data --single-transaction test
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo 4. --master-data=2 --dump-slave=2 --single-transaction --gtid (MDEV-4827)
|
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/ /MariaDB dump.*/MariaDB dump/ /Dump completed.*/Dump completed/ /Server version.*/Server version/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --master-data=2 --dump-slave=2 --single-transaction --gtid test
|
|
|
|
--echo
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo 4a. --master-data=2 --dump-slave=2 --single-transaction (MDEV-4827)
|
|
|
|
--echo
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/ /MariaDB dump.*/MariaDB dump/ /Dump completed.*/Dump completed/ /Server version.*/Server version/
|
|
|
|
--exec $MYSQL_DUMP_SLAVE --master-data=2 --dump-slave=2 --single-transaction test
|
|
|
|
--echo
|
2023-11-18 14:38:10 +01:00
|
|
|
#
|
|
|
|
# MDEV-32611 Added test for mysqldump --delete-master-logs option.
|
2023-12-05 22:27:39 +01:00
|
|
|
# This options is alias of
|
2023-11-18 14:38:10 +01:00
|
|
|
# get binlogs: show master status -> flush logs -> purge binary logs to <new_binlog>
|
|
|
|
# sequence and this test is derived using the same pattern.
|
|
|
|
#
|
|
|
|
|
|
|
|
connection master;
|
|
|
|
|
|
|
|
CREATE TABLE t (
|
|
|
|
id int
|
|
|
|
);
|
|
|
|
|
|
|
|
insert into t values (1);
|
|
|
|
insert into t values (2);
|
|
|
|
|
|
|
|
drop table t;
|
|
|
|
|
2023-12-05 22:27:39 +01:00
|
|
|
--sync_slave_with_master
|
|
|
|
|
|
|
|
# MDEV-32953: Because --delete-master-logs immediately purges logs after
|
|
|
|
# flushing, it is possible the binlog dump threads will still be using the old
|
|
|
|
# log when the purge executes, disallowing the file from being deleted.
|
|
|
|
# Therefore, we temporarily stop the slave so there is no chance the old binlog
|
|
|
|
# is still being referenced. master_use_gtid=Slave_pos is necessary to still
|
|
|
|
# appear up-to-date to the master on restart after the master has flushed the
|
|
|
|
# logs (while the slave is offline). Otherwise (i.e. if using binlog file/pos),
|
|
|
|
# the slave would point to a purged log file, and receive an error immediately
|
|
|
|
# upon connecting to the master.
|
|
|
|
--source include/stop_slave.inc
|
|
|
|
change master to master_use_gtid=slave_pos;
|
|
|
|
|
|
|
|
connection master;
|
|
|
|
|
|
|
|
--echo # Ensuring the binlog dump thread is killed on primary...
|
|
|
|
--disable_query_log
|
|
|
|
--let $binlog_dump_thd_tid= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND LIKE 'Binlog Dump'`
|
|
|
|
if ($binlog_dump_thd_tid)
|
|
|
|
{
|
|
|
|
--eval kill $binlog_dump_thd_tid
|
|
|
|
}
|
|
|
|
--let $wait_condition= SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND LIKE 'Binlog Dump'
|
|
|
|
--source include/wait_condition.inc
|
|
|
|
--enable_query_log
|
|
|
|
|
2023-11-18 14:38:10 +01:00
|
|
|
--let $predump_binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1)
|
|
|
|
|
|
|
|
# Execute mysqldump with delete-master-logs option
|
|
|
|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
|
|
|
|
--exec $MYSQL_DUMP --compact --no-create-info --no-data --delete-master-logs test
|
|
|
|
|
|
|
|
--let $postdump_binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1)
|
|
|
|
|
|
|
|
--let $postdump_first_binary_log_filename= query_get_value(SHOW BINARY LOGS, Log_name, 1)
|
|
|
|
|
|
|
|
if ($predump_binlog_filename == $postdump_binlog_filename)
|
|
|
|
{
|
|
|
|
--echo # predump_binlog_filename: $predump_binlog_filename
|
|
|
|
--echo # postdump_binlog_filename: $postdump_binlog_filename
|
|
|
|
--die Master state didn't change after mariadb-dump with --delete-master-logs.
|
|
|
|
}
|
MDEV-6336: mysqldump --master-data does not work with GTID setups
MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated
Add a --gtid option (for compatibility, the original behaviour is preserved
when --gtid is not used).
With --gtid, --master-data and --dump-slave output the GTID position (the
old-style file/offset position is still output, but commented out). Also, a
CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned
slave is configured in GTID, as requested.
Without --gtid, the GTID position is still output, if available, but commented
out.
Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a
mysqldump on a slave server will silently inject a GTID which does not exist
on the master, which is highly undesirable.
Also fix an incorrect error handling around obtaining binlog position with
--master-data (was probably unlikely to trigger in most cases).
2014-07-09 13:36:28 +02:00
|
|
|
|
2023-11-18 14:38:10 +01:00
|
|
|
if ($postdump_first_binary_log_filename != $postdump_binlog_filename)
|
|
|
|
{
|
|
|
|
--echo # postdump_first_binary_log_filename: $postdump_first_binary_log_filename
|
|
|
|
--echo # postdump_binlog_filename: $postdump_binlog_filename
|
|
|
|
--die Master binlog wasn't deleted after mariadb-dump with --delete-master-logs.
|
|
|
|
}
|
MDEV-6336: mysqldump --master-data does not work with GTID setups
MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated
Add a --gtid option (for compatibility, the original behaviour is preserved
when --gtid is not used).
With --gtid, --master-data and --dump-slave output the GTID position (the
old-style file/offset position is still output, but commented out). Also, a
CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned
slave is configured in GTID, as requested.
Without --gtid, the GTID position is still output, if available, but commented
out.
Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a
mysqldump on a slave server will silently inject a GTID which does not exist
on the master, which is highly undesirable.
Also fix an incorrect error handling around obtaining binlog position with
--master-data (was probably unlikely to trigger in most cases).
2014-07-09 13:36:28 +02:00
|
|
|
|
2023-12-05 22:27:39 +01:00
|
|
|
connection slave;
|
|
|
|
--source include/start_slave.inc
|
|
|
|
|
2010-12-19 18:15:12 +01:00
|
|
|
--source include/rpl_end.inc
|