All Products
Search
Document Center

ApsaraDB RDS:What do I do if a primary/secondary switchover is triggered when I run the mysqldump command on my ApsaraDB RDS for MySQL instance?

Last Updated:Mar 28, 2026

This happens when you use --master-data without --single-transaction. Running mysqldump with --master-data alone causes FLUSH TABLES WITH READ LOCK to execute, which blocks all Data Manipulation Language (DML) operations for the entire duration of the dump. The high availability (HA) component on the primary instance periodically runs DML statements to check instance health — if those statements are blocked long enough, the HA failure detection mechanism concludes the primary instance is unavailable and triggers a switchover.

Solution

Always pair --master-data with --single-transaction. The --single-transaction flag opens a consistent snapshot before the dump begins, so mysqldump can read data without holding a global read lock. The UNLOCK TABLES statement is then executed to release any remaining locks, allowing DML operations to continue uninterrupted and the HA component to keep running its health checks normally — no switchover is triggered.

mysqldump -h127.0.0.1 -usystem -p123456 --master-data=2 --single-transaction --set-gtid-purged=OFF --all-databases --triggers --events --routines> /tmp/all_master.sql