diff --git a/cmd/go-mysqlbinlog/main.go b/cmd/go-mysqlbinlog/main.go index eb97ace9c..993672937 100644 --- a/cmd/go-mysqlbinlog/main.go +++ b/cmd/go-mysqlbinlog/main.go @@ -40,13 +40,14 @@ func main() { ServerID: 101, Flavor: *flavor, - Host: *host, - Port: uint16(*port), - User: *user, - Password: *password, - RawModeEnabled: *rawMode, - SemiSyncEnabled: *semiSync, - UseDecimal: true, + Host: *host, + Port: uint16(*port), + User: *user, + Password: *password, + RawModeEnabled: *rawMode, + SemiSyncEnabled: *semiSync, + UseDecimal: true, + MaxReconnectAttempts: 10, } b := replication.NewBinlogSyncer(cfg) diff --git a/replication/binlogsyncer.go b/replication/binlogsyncer.go index aed7f2d77..e0323d939 100644 --- a/replication/binlogsyncer.go +++ b/replication/binlogsyncer.go @@ -749,12 +749,18 @@ func (b *BinlogSyncer) onStream(s *BinlogStreamer) { b.retryCount++ if err = b.retrySync(); err != nil { if b.cfg.MaxReconnectAttempts > 0 && b.retryCount >= b.cfg.MaxReconnectAttempts { - b.cfg.Logger.Errorf("retry sync err: %v, exceeded max retries (%d)", err, b.cfg.MaxReconnectAttempts) + b.cfg.Logger.Errorf( + "retry sync err: %v, exceeded max retries (%d)", + err, b.cfg.MaxReconnectAttempts, + ) s.closeWithError(err) return } - b.cfg.Logger.Errorf("retry sync err: %v, wait 1s and retry again", err) + b.cfg.Logger.Errorf( + "retry sync err: %v, wait 1s and retry again (retries: %d/%d)", + err, b.retryCount, b.cfg.MaxReconnectAttempts, + ) continue } }