Skip to content

refine usage of MaxReconnectAttempts in BinlogSyncer #417

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

Merged
Merged
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
12 changes: 11 additions & 1 deletion replication/binlogsyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ type BinlogSyncerConfig struct {
// read timeout
ReadTimeout time.Duration

// maximum number of attempts to re-establish a broken connection
// maximum number of attempts to re-establish a broken connection, zero or negative number means infinite retry.
// this configuration will not work if DisableRetrySync is true
MaxReconnectAttempts int

// whether disable re-sync for broken connection
DisableRetrySync bool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting MaxReconnectAttempts = 0 is not enough?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer changing the way of MaxReconnectAttempts

Copy link
Contributor Author

@amyangfei amyangfei Sep 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then what about

  • MaxReconnectAttempts < 0, no retry
  • MaxReconnectAttempts = 0, infinite retry
  • MaxReconnectAttempts > 0, retry for MaxReconnectAttempts time

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, for < 0, we can change the value to MaxInt


// Only works when MySQL/MariaDB variable binlog_checksum=CRC32.
// For MySQL, binlog_checksum was introduced since 5.6.2, but CRC32 was set as default value since 5.6.6 .
// https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#option_mysqld_binlog-checksum
Expand Down Expand Up @@ -645,6 +649,12 @@ func (b *BinlogSyncer) onStream(s *BinlogStreamer) {
return
}

if b.cfg.DisableRetrySync {
log.Warn("retry sync is disabled")
s.closeWithError(err)
return
}

for {
select {
case <-b.ctx.Done():
Expand Down