Skip to content

Commit f52d30c

Browse files
amyangfeisiddontang
authored andcommitted
refine usage of MaxReconnectAttempts in BinlogSyncer (#417)
* refine usage of MaxReconnectAttempts in BinlogSyncer
1 parent be37886 commit f52d30c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

replication/binlogsyncer.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@ type BinlogSyncerConfig struct {
8383
// read timeout
8484
ReadTimeout time.Duration
8585

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

90+
// whether disable re-sync for broken connection
91+
DisableRetrySync bool
92+
8993
// Only works when MySQL/MariaDB variable binlog_checksum=CRC32.
9094
// For MySQL, binlog_checksum was introduced since 5.6.2, but CRC32 was set as default value since 5.6.6 .
9195
// https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#option_mysqld_binlog-checksum
@@ -645,6 +649,12 @@ func (b *BinlogSyncer) onStream(s *BinlogStreamer) {
645649
return
646650
}
647651

652+
if b.cfg.DisableRetrySync {
653+
log.Warn("retry sync is disabled")
654+
s.closeWithError(err)
655+
return
656+
}
657+
648658
for {
649659
select {
650660
case <-b.ctx.Done():

0 commit comments

Comments
 (0)