Open asiroliu opened 2 years ago
MySQL circle - two jobs send ddl cyclically
MySQL-1> CREATE TABLE tb1 (id INT(11) AUTO_INCREMENT PRIMARY KEY); MySQL-2> CREATE TABLE tb2 (id INT(11) AUTO_INCREMENT PRIMARY KEY);
# job-1 MySQL-1 to MySQL-2 "ReplicateDoDb": [ { "TableSchema": "test", "Tables": [] } ], "DropTableIfExists": false, "SkipCreateDbTable": true
# job-2 MySQL-2 to MySQL-1 "ReplicateDoDb": [ { "TableSchema": "test", "Tables": [] } ], "DropTableIfExists": false, "SkipCreateDbTable": true
SQL> set global general_log = ON; SQL> set global general_log_file = '/tmp/general.log';
2021-11-02T09:49:25.845630Z 12 Query START TRANSACTION 2021-11-02T09:49:25.845845Z 12 Query USE `test` 2021-11-02T09:49:25.846258Z 12 Query set @@session.foreign_key_checks = 0 2021-11-02T09:49:25.846396Z 12 Query DROP TABLE IF EXISTS `tb1` /* generated by server */ /*dtle_gtid1 dtle-6-1-migration e9ebc730-3bbf-11ec-ad98-0242ac640901 279483 dtle_gtid*/ 2021-11-02T09:49:25.846845Z 12 Query set @@session.foreign_key_checks = 1 2021-11-02T09:49:25.846986Z 12 Execute replace into dtle.gtid_executed_v4 (job_name,source_uuid,gtid,gtid_set) values (?, ?, ?, null) 2021-11-02T09:49:25.847674Z 12 Query COMMIT 2021-11-02T09:49:25.848977Z 12 Query START TRANSACTION 2021-11-02T09:49:25.849258Z 12 Query USE `test` 2021-11-02T09:49:25.849541Z 12 Query set @@session.foreign_key_checks = 0 2021-11-02T09:49:25.849692Z 12 Query DROP TABLE IF EXISTS `tb2` /* generated by server */ /*dtle_gtid1 dtle-6-1-migration e9ebc730-3bbf-11ec-ad98-0242ac640901 279485 dtle_gtid*/ 2021-11-02T09:49:25.850357Z 12 Query set @@session.foreign_key_checks = 1 2021-11-02T09:49:25.850513Z 12 Execute replace into dtle.gtid_executed_v4 (job_name,source_uuid,gtid,gtid_set) values (?, ?, ?, null) 2021-11-02T09:49:25.851050Z 12 Query COMMIT 2021-11-02T09:49:25.851559Z 12 Query START TRANSACTION 2021-11-02T09:49:25.851801Z 12 Query USE `test` 2021-11-02T09:49:25.852055Z 12 Query set @@session.foreign_key_checks = 0 2021-11-02T09:49:25.852273Z 12 Query DROP TABLE IF EXISTS `tb1` /* generated by server */ /*dtle_gtid1 dtle-6-1-migration e9ebc730-3bbf-11ec-ad98-0242ac640901 279487 dtle_gtid*/ 2021-11-02T09:49:25.852882Z 12 Query set @@session.foreign_key_checks = 1 2021-11-02T09:49:25.853122Z 12 Execute replace into dtle.gtid_executed_v4 (job_name,source_uuid,gtid,gtid_set) values (?, ?, ?, null) 2021-11-02T09:49:25.853685Z 12 Query COMMIT 2021-11-02T09:49:25.854816Z 12 Query START TRANSACTION 2021-11-02T09:49:25.854968Z 12 Query USE `test` 2021-11-02T09:49:25.855167Z 12 Query set @@session.foreign_key_checks = 0 2021-11-02T09:49:25.855282Z 12 Query DROP TABLE IF EXISTS `tb2` /* generated by server */ /*dtle_gtid1 dtle-6-1-migration e9ebc730-3bbf-11ec-ad98-0242ac640901 279489 dtle_gtid*/ 2021-11-02T09:49:25.855847Z 12 Query set @@session.foreign_key_checks = 1 2021-11-02T09:49:25.856010Z 12 Execute replace into dtle.gtid_executed_v4 (job_name,source_uuid,gtid,gtid_set) values (?, ?, ?, null) 2021-11-02T09:49:25.856398Z 12 Query COMMIT 2021-11-02T0
the dll should execute once
./dtle version
9.9.9.9-master-ef8ac77
(e.g. issue happens only occasionally)
分析
drop table ... /*dtle gtid tag*/
DROP TABLE /* generated by server */
对于不带if exists的drop table语句, dtle“歪打正着”避免了循环复制. 其原因为: drop 再次执行时, 表不存在, 失败. 语句不会写入binlog.
if exists
drop table
Description
MySQL circle - two jobs send ddl cyclically
Steps to reproduce the issue
Describe the results you expected
the dll should execute once
Output of
./dtle version
:**Additional information
(e.g. issue happens only occasionally)
Additional details (log, config, job config etc):