diff --git a/dm/relay/relay.go b/dm/relay/relay.go index 8a0e6da3b7d..da722b82894 100644 --- a/dm/relay/relay.go +++ b/dm/relay/relay.go @@ -1151,6 +1151,12 @@ func (r *Relay) setSyncConfig() error { } } + h, _ := os.Hostname() + h = "dm-relay-" + h + // https://github.com/mysql/mysql-server/blob/1bfe02bdad6604d54913c62614bde57a055c8332/include/my_hostname.h#L33-L42 + if len(h) > 60 { + h = h[:60] + } syncerCfg := replication.BinlogSyncerConfig{ ServerID: r.cfg.ServerID, Flavor: r.cfg.Flavor, @@ -1160,6 +1166,7 @@ func (r *Relay) setSyncConfig() error { Password: r.cfg.From.Password, Charset: r.cfg.Charset, TLSConfig: tlsConfig, + Localhost: h, } common.SetDefaultReplicationCfg(&syncerCfg, common.MaxBinlogSyncerReconnect) diff --git a/dm/syncer/util.go b/dm/syncer/util.go index cf626a4b103..464067c3631 100644 --- a/dm/syncer/util.go +++ b/dm/syncer/util.go @@ -196,6 +196,11 @@ func subtaskCfg2BinlogSyncerCfg(cfg *config.SubTaskConfig, timezone *time.Locati } } + h := cfg.WorkerName + // https://github.com/mysql/mysql-server/blob/1bfe02bdad6604d54913c62614bde57a055c8332/include/my_hostname.h#L33-L42 + if len(h) > 60 { + h = h[:60] + } syncCfg := replication.BinlogSyncerConfig{ ServerID: cfg.ServerID, Flavor: cfg.Flavor, @@ -206,6 +211,7 @@ func subtaskCfg2BinlogSyncerCfg(cfg *config.SubTaskConfig, timezone *time.Locati TimestampStringLocation: timezone, TLSConfig: tlsConfig, RowsEventDecodeFunc: rowsEventDecodeFunc, + Localhost: h, } // when retry count > 1, go-mysql will retry sync from the previous GTID set in GTID mode, // which may get duplicate binlog event after retry success. so just set retry count = 1, and task