Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-mysqlbinlog: set to retry only 10 times #945

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions cmd/go-mysqlbinlog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions replication/binlogsyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down