galera mysqldump --master-data 備份阻塞

最近 galera 出現了兩次 hang 住的情況,是由於使用 mysqldump 備份時使用 --master-data 選項導致。

 

先看官方文檔
--master-data[=value]
Use this option to dump a master replication server to produce a dump file that can be used to set up another server as a slave of the master. It causes the dump output to include a CHANGE MASTER TO statement that indicates the binary log coordinates (file name and position) of the dumped server. These are the master server coordinates from which the slave should start replicating after you load
the dump file into the slave. 

If the option value is 2, the CHANGE MASTER TO statement is written as an SQL comment, and thus is informative only; it has no effect when the dump file is reloaded. If the option value is 1, the statement is not written as a comment and takes effect when the dump file is reloaded. If no option value is specified, the default value is 1.
This option requires the RELOAD privilege and the binary log must be enabled.

The --master-data option automatically turns off --lock-tables. It also turns on --lock-all-tables, unless --single-transaction also is specified, in which case, a global read lock is acquired only for a short time at the beginning of the dump (see the description for --single-transaction). In all cases, any action on logs happens at the exact moment of the dump.

It is also possible to set up a slave by dumping an existing slave of the master, using the --dump-slave option, which overrides --master-data and causes it to be ignored if both options are used.

從官方文檔中看到,使用 --master-data 選項會導致 mysql 執行 FLUSH TABLES WITH READ LOCK。在 general log 中可以看到。


那麼問題來了,在 galera cluster 中,對於 DDL 的執行,首先是強制進入了 TOI(Total Order Isolation),導致所有相關其他節點的事務都會被殺死,並且整個表操作都會在 Commit 的臨界區做,導致其他事務的提交都做不了。詳情請戳:http://galeracluster.com/documentation-webpages/schemaupgrades.html

最後,galera 的介紹:https://www.sohu.com/a/147032902_505779

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章