Skip to content

Commit 0a033c7

Browse files
shaohkshaohoukun
andauthored
feat(feat-set-binlogsyncer-maxreconnectattempts): feat-set-binlogsyncer-maxreconnectattempts (#1279)
Co-authored-by: shaohoukun <[email protected]>
1 parent b7db8c6 commit 0a033c7

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

doc/command-line-flags.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ It is not reliable to parse the `ALTER` statement to determine if it is instant
6161

6262
`gh-ost` will automatically fallback to the normal DDL process if the attempt to use instant DDL is unsuccessful.
6363

64+
### binlogsyncer-max-reconnect-attempts
65+
`--binlogsyncer-max-reconnect-attempts=0`, the maximum number of attempts to re-establish a broken inspector connection for sync binlog. `0` or `negative number` means infinite retry, default `0`
66+
6467
### conf
6568

6669
`--conf=/path/to/my.cnf`: file where credentials are specified. Should be in (or contain) the following format:

go/base/context.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ type MigrationContext struct {
232232

233233
recentBinlogCoordinates mysql.BinlogCoordinates
234234

235+
BinlogSyncerMaxReconnectAttempts int
236+
235237
Log Logger
236238
}
237239

go/binlog/gomysql_reader.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ func NewGoMySQLReader(migrationContext *base.MigrationContext) *GoMySQLReader {
3636
currentCoordinates: mysql.BinlogCoordinates{},
3737
currentCoordinatesMutex: &sync.Mutex{},
3838
binlogSyncer: replication.NewBinlogSyncer(replication.BinlogSyncerConfig{
39-
ServerID: uint32(migrationContext.ReplicaServerId),
40-
Flavor: gomysql.MySQLFlavor,
41-
Host: connectionConfig.Key.Hostname,
42-
Port: uint16(connectionConfig.Key.Port),
43-
User: connectionConfig.User,
44-
Password: connectionConfig.Password,
45-
TLSConfig: connectionConfig.TLSConfig(),
46-
UseDecimal: true,
39+
ServerID: uint32(migrationContext.ReplicaServerId),
40+
Flavor: gomysql.MySQLFlavor,
41+
Host: connectionConfig.Key.Hostname,
42+
Port: uint16(connectionConfig.Key.Port),
43+
User: connectionConfig.User,
44+
Password: connectionConfig.Password,
45+
TLSConfig: connectionConfig.TLSConfig(),
46+
UseDecimal: true,
47+
MaxReconnectAttempts: migrationContext.BinlogSyncerMaxReconnectAttempts,
4748
}),
4849
}
4950
}

go/cmd/gh-ost/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func main() {
134134
flag.Int64Var(&migrationContext.HooksStatusIntervalSec, "hooks-status-interval", 60, "how many seconds to wait between calling onStatus hook")
135135

136136
flag.UintVar(&migrationContext.ReplicaServerId, "replica-server-id", 99999, "server id used by gh-ost process. Default: 99999")
137+
flag.IntVar(&migrationContext.BinlogSyncerMaxReconnectAttempts, "binlogsyncer-max-reconnect-attempts", 0, "when master node fails, the maximum number of binlog synchronization attempts to reconnect. 0 is unlimited")
137138

138139
maxLoad := flag.String("max-load", "", "Comma delimited status-name=threshold. e.g: 'Threads_running=100,Threads_connected=500'. When status exceeds threshold, app throttles writes")
139140
criticalLoad := flag.String("critical-load", "", "Comma delimited status-name=threshold, same format as --max-load. When status exceeds threshold, app panics and quits")

0 commit comments

Comments
 (0)