-
Notifications
You must be signed in to change notification settings - Fork 2
Fix MySQL 8.4+/9.x replication compatibility #21
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -182,6 +182,18 @@ func CreateAllMastersReplication(sandboxDef SandboxDef, origin string, nodes int | |||||||||||||||||||||||||||||||
| data["RplPassword"] = sandboxDef.RplPassword | ||||||||||||||||||||||||||||||||
| data["NodeLabel"] = defaults.Defaults().NodePrefix | ||||||||||||||||||||||||||||||||
| data["ChangeMasterExtra"] = setChangeMasterProperties("", sandboxDef.ChangeMasterOptions, logger) | ||||||||||||||||||||||||||||||||
| replCmds := replicationCommands(sandboxDef.Version) | ||||||||||||||||||||||||||||||||
| data["ShowMasterStatus"] = replCmds["ShowMasterStatus"] | ||||||||||||||||||||||||||||||||
| data["ShowSlaveStatus"] = replCmds["ShowSlaveStatus"] | ||||||||||||||||||||||||||||||||
| data["ChangeMasterTo"] = replCmds["ChangeMasterTo"] | ||||||||||||||||||||||||||||||||
| data["StartReplica"] = replCmds["StartReplica"] | ||||||||||||||||||||||||||||||||
| data["StopReplica"] = replCmds["StopReplica"] | ||||||||||||||||||||||||||||||||
| data["ResetReplica"] = replCmds["ResetReplica"] | ||||||||||||||||||||||||||||||||
| data["MasterPosWaitFunc"] = replCmds["MasterPosWaitFunc"] | ||||||||||||||||||||||||||||||||
| data["MasterHostParam"] = replCmds["MasterHostParam"] | ||||||||||||||||||||||||||||||||
| data["MasterPortParam"] = replCmds["MasterPortParam"] | ||||||||||||||||||||||||||||||||
| data["MasterUserParam"] = replCmds["MasterUserParam"] | ||||||||||||||||||||||||||||||||
| data["MasterPasswordParam"] = replCmds["MasterPasswordParam"] | ||||||||||||||||||||||||||||||||
| logger.Printf("Writing master and slave scripts in %s\n", sandboxDef.SandboxDir) | ||||||||||||||||||||||||||||||||
| for _, node := range slaveList { | ||||||||||||||||||||||||||||||||
| data["Node"] = node | ||||||||||||||||||||||||||||||||
|
|
@@ -407,6 +419,18 @@ func CreateFanInReplication(sandboxDef SandboxDef, origin string, nodes int, mas | |||||||||||||||||||||||||||||||
| data["NodeLabel"] = defaults.Defaults().NodePrefix | ||||||||||||||||||||||||||||||||
| data["ChangeMasterExtra"] = setChangeMasterProperties("", sandboxDef.ChangeMasterOptions, logger) | ||||||||||||||||||||||||||||||||
| data["MasterIp"] = masterIp | ||||||||||||||||||||||||||||||||
| replCmds := replicationCommands(sandboxDef.Version) | ||||||||||||||||||||||||||||||||
| data["ShowMasterStatus"] = replCmds["ShowMasterStatus"] | ||||||||||||||||||||||||||||||||
| data["ShowSlaveStatus"] = replCmds["ShowSlaveStatus"] | ||||||||||||||||||||||||||||||||
| data["ChangeMasterTo"] = replCmds["ChangeMasterTo"] | ||||||||||||||||||||||||||||||||
| data["StartReplica"] = replCmds["StartReplica"] | ||||||||||||||||||||||||||||||||
| data["StopReplica"] = replCmds["StopReplica"] | ||||||||||||||||||||||||||||||||
| data["ResetReplica"] = replCmds["ResetReplica"] | ||||||||||||||||||||||||||||||||
| data["MasterPosWaitFunc"] = replCmds["MasterPosWaitFunc"] | ||||||||||||||||||||||||||||||||
| data["MasterHostParam"] = replCmds["MasterHostParam"] | ||||||||||||||||||||||||||||||||
| data["MasterPortParam"] = replCmds["MasterPortParam"] | ||||||||||||||||||||||||||||||||
| data["MasterUserParam"] = replCmds["MasterUserParam"] | ||||||||||||||||||||||||||||||||
| data["MasterPasswordParam"] = replCmds["MasterPasswordParam"] | ||||||||||||||||||||||||||||||||
|
Comment on lines
+422
to
+433
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the
Suggested change
|
||||||||||||||||||||||||||||||||
| logger.Printf("Writing master and slave scripts in %s\n", sandboxDef.SandboxDir) | ||||||||||||||||||||||||||||||||
| for _, slave := range slist { | ||||||||||||||||||||||||||||||||
| data["Node"] = slave | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,47 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/pkg/errors" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func replicationCommands(version string) map[string]string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds := map[string]string{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "ShowMasterStatus": "show master status", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "ShowSlaveStatus": "show slave status", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "ChangeMasterTo": "CHANGE MASTER TO", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "StartReplica": "START SLAVE", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "StopReplica": "STOP SLAVE", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "ResetReplica": "RESET SLAVE", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "MasterPosWaitFunc": "master_pos_wait", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "MasterHostParam": "master_host", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "MasterPortParam": "master_port", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "MasterUserParam": "master_user", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "MasterPasswordParam": "master_password", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useReplicaStatus, _ := common.GreaterOrEqualVersion(version, globals.MinimumShowReplicaStatusVersion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if useReplicaStatus { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds["ShowSlaveStatus"] = "show replica status" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds["StartReplica"] = "START REPLICA" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds["StopReplica"] = "STOP REPLICA" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds["ResetReplica"] = "RESET REPLICA" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds["MasterPosWaitFunc"] = "source_pos_wait" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useChangeSource, _ := common.GreaterOrEqualVersion(version, globals.MinimumChangeReplicationSourceVersion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if useChangeSource { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds["ChangeMasterTo"] = "CHANGE REPLICATION SOURCE TO" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds["MasterHostParam"] = "source_host" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds["MasterPortParam"] = "source_port" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds["MasterUserParam"] = "source_user" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds["MasterPasswordParam"] = "source_password" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useBinaryLogStatus, _ := common.GreaterOrEqualVersion(version, globals.MinimumShowBinaryLogStatusVersion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if useBinaryLogStatus { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmds["ShowMasterStatus"] = "show binary log status" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+47
to
+69
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useReplicaStatus, _ := common.GreaterOrEqualVersion(version, globals.MinimumShowReplicaStatusVersion) | |
| if useReplicaStatus { | |
| cmds["ShowSlaveStatus"] = "show replica status" | |
| cmds["StartReplica"] = "START REPLICA" | |
| cmds["StopReplica"] = "STOP REPLICA" | |
| cmds["ResetReplica"] = "RESET REPLICA" | |
| cmds["MasterPosWaitFunc"] = "source_pos_wait" | |
| } | |
| useChangeSource, _ := common.GreaterOrEqualVersion(version, globals.MinimumChangeReplicationSourceVersion) | |
| if useChangeSource { | |
| cmds["ChangeMasterTo"] = "CHANGE REPLICATION SOURCE TO" | |
| cmds["MasterHostParam"] = "source_host" | |
| cmds["MasterPortParam"] = "source_port" | |
| cmds["MasterUserParam"] = "source_user" | |
| cmds["MasterPasswordParam"] = "source_password" | |
| } | |
| useBinaryLogStatus, _ := common.GreaterOrEqualVersion(version, globals.MinimumShowBinaryLogStatusVersion) | |
| if useBinaryLogStatus { | |
| cmds["ShowMasterStatus"] = "show binary log status" | |
| } | |
| versionList, err := common.VersionToList(version) | |
| if err != nil { | |
| fmt.Fprintf(os.Stderr, "warning: unable to parse MySQL version %q: %v; using legacy replication commands\n", version, err) | |
| return cmds | |
| } | |
| minShowReplicaStatusVersionList, err := common.VersionToList(globals.MinimumShowReplicaStatusVersion) | |
| if err != nil { | |
| fmt.Fprintf(os.Stderr, "warning: unable to parse minimum show replica status version %q: %v; leaving slave status commands unchanged\n", globals.MinimumShowReplicaStatusVersion, err) | |
| } else { | |
| useReplicaStatus := common.GreaterOrEqualVersionList(versionList, minShowReplicaStatusVersionList) | |
| if useReplicaStatus { | |
| cmds["ShowSlaveStatus"] = "show replica status" | |
| cmds["StartReplica"] = "START REPLICA" | |
| cmds["StopReplica"] = "STOP REPLICA" | |
| cmds["ResetReplica"] = "RESET REPLICA" | |
| cmds["MasterPosWaitFunc"] = "source_pos_wait" | |
| } | |
| } | |
| minChangeSourceVersionList, err := common.VersionToList(globals.MinimumChangeReplicationSourceVersion) | |
| if err != nil { | |
| fmt.Fprintf(os.Stderr, "warning: unable to parse minimum change replication source version %q: %v; leaving CHANGE MASTER TO command unchanged\n", globals.MinimumChangeReplicationSourceVersion, err) | |
| } else { | |
| useChangeSource := common.GreaterOrEqualVersionList(versionList, minChangeSourceVersionList) | |
| if useChangeSource { | |
| cmds["ChangeMasterTo"] = "CHANGE REPLICATION SOURCE TO" | |
| cmds["MasterHostParam"] = "source_host" | |
| cmds["MasterPortParam"] = "source_port" | |
| cmds["MasterUserParam"] = "source_user" | |
| cmds["MasterPasswordParam"] = "source_password" | |
| } | |
| } | |
| minBinaryLogStatusVersionList, err := common.VersionToList(globals.MinimumShowBinaryLogStatusVersion) | |
| if err != nil { | |
| fmt.Fprintf(os.Stderr, "warning: unable to parse minimum show binary log status version %q: %v; leaving master status command unchanged\n", globals.MinimumShowBinaryLogStatusVersion, err) | |
| } else { | |
| useBinaryLogStatus := common.GreaterOrEqualVersionList(versionList, minBinaryLogStatusVersionList) | |
| if useBinaryLogStatus { | |
| cmds["ShowMasterStatus"] = "show binary log status" | |
| } | |
| } |
Copilot
AI
Mar 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This uses common.GreaterOrEqualVersion (deprecated) and ignores the parse error. If sandboxDef.Version isn’t strictly x.y.z (e.g., includes a prefix), this will silently choose GET_MASTER_PUBLIC_KEY even when the new CHANGE REPLICATION SOURCE TO syntax is active, which can break authentication on newer MySQL. Prefer common.HasCapability (new feature flag) or compare parsed version lists and handle the error explicitly.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,13 +12,13 @@ do | |||||
| port=$($SBDIR/{{.NodeLabel}}$M/use -BN -e "show variables like 'port'") | ||||||
| server_id=$($SBDIR/{{.NodeLabel}}$M/use -BN -e "show variables like 'server_id'") | ||||||
| echo "$port - $server_id" | ||||||
| $SBDIR/{{.NodeLabel}}$M/use -e 'show master status\G' | grep "File\|Position\|Executed" | ||||||
| $SBDIR/{{.NodeLabel}}$M/use -e '{{.ShowMasterStatus}}\G' | grep "File\|Position\|Executed" | ||||||
| done | ||||||
| for S in $SLAVES | ||||||
| do | ||||||
| echo "# Slave $S" | ||||||
| port=$($SBDIR/{{.NodeLabel}}$S/use -BN -e "show variables like 'port'") | ||||||
| server_id=$($SBDIR/{{.NodeLabel}}$S/use -BN -e "show variables like 'server_id'") | ||||||
| echo "$port - $server_id" | ||||||
| $SBDIR/{{.NodeLabel}}$S/use -e 'show slave status\G' | grep "\(Running:\|Master_Log_Pos\|\<Master_Log_File\|Retrieved\|Channel\|Executed\)" | ||||||
| $SBDIR/{{.NodeLabel}}$S/use -e '{{.ShowSlaveStatus}}\G' | grep -E "(Running:|Master_Log_Pos|Source_Log_Pos|\<Master_Log_File|\<Source_Log_File|Retrieved|Channel|Executed)" | ||||||
|
||||||
| $SBDIR/{{.NodeLabel}}$S/use -e '{{.ShowSlaveStatus}}\G' | grep -E "(Running:|Master_Log_Pos|Source_Log_Pos|\<Master_Log_File|\<Source_Log_File|Retrieved|Channel|Executed)" | |
| $SBDIR/{{.NodeLabel}}$S/use -e '{{.ShowSlaveStatus}}\G' | grep -E "(Running:|Master_Log_Pos|Source_Log_Pos|Master_Log_File:|Source_Log_File:|Retrieved|Channel|Executed)" |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,11 +6,11 @@ echo "{{.MasterLabel}}" | |||||
| port=$($SBDIR/{{.MasterLabel}}/use -BN -e "show variables like 'port'") | ||||||
| server_id=$($SBDIR/{{.MasterLabel}}/use -BN -e "show variables like 'server_id'") | ||||||
| echo "$port - $server_id" | ||||||
| $SBDIR/{{.MasterLabel}}/use -e 'show master status\G' | grep "File\|Position\|Executed" | ||||||
| $SBDIR/{{.MasterLabel}}/use -e '{{.ShowMasterStatus}}\G' | grep "File\|Position\|Executed" | ||||||
| {{ range .Slaves }} | ||||||
| echo "{{.SlaveLabel}}{{.Node}}" | ||||||
| port=$($SBDIR/{{.NodeLabel}}{{.Node}}/use -BN -e "show variables like 'port'") | ||||||
| server_id=$($SBDIR/{{.NodeLabel}}{{.Node}}/use -BN -e "show variables like 'server_id'") | ||||||
| echo "$port - $server_id" | ||||||
| $SBDIR/{{.NodeLabel}}{{.Node}}/use -e 'show slave status\G' | grep "\(Running:\|Master_Log_Pos\|\<Master_Log_File\|Retrieved\|Executed\|Auto_Position\)" | ||||||
| $SBDIR/{{.NodeLabel}}{{.Node}}/use -e '{{.ShowSlaveStatus}}\G' | grep -E "(Running:|Master_Log_Pos|Source_Log_Pos|\<Master_Log_File|\<Source_Log_File|Retrieved|Executed|Auto_Position)" | ||||||
|
||||||
| $SBDIR/{{.NodeLabel}}{{.Node}}/use -e '{{.ShowSlaveStatus}}\G' | grep -E "(Running:|Master_Log_Pos|Source_Log_Pos|\<Master_Log_File|\<Source_Log_File|Retrieved|Executed|Auto_Position)" | |
| $SBDIR/{{.NodeLabel}}{{.Node}}/use -e '{{.ShowSlaveStatus}}\G' | grep -E "(Running:|Master_Log_Pos|Source_Log_Pos|Master_Log_File:|Source_Log_File:|Retrieved|Executed|Auto_Position)" |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,7 +29,7 @@ MASTER_RECS=$($MASTER -BN -e 'select count(*) from test.t1') | |||||||||||||
|
|
||||||||||||||
| master_status=master_status$$ | ||||||||||||||
| slave_status=slave_status$$ | ||||||||||||||
| $MASTER -e 'show master status\G' > $master_status | ||||||||||||||
| $MASTER -e '{{.ShowMasterStatus}}\G' > $master_status | ||||||||||||||
| master_binlog=$(grep 'File:' $master_status | awk '{print $2}' ) | ||||||||||||||
| master_pos=$(grep 'Position:' $master_status | awk '{print $2}' ) | ||||||||||||||
| echo "# {{.MasterLabel}} log: $master_binlog - Position: $master_pos - Rows: $MASTER_RECS" | ||||||||||||||
|
|
@@ -98,7 +98,7 @@ do | |||||||||||||
| then | ||||||||||||||
| sleep 3 | ||||||||||||||
| else | ||||||||||||||
| S_READY=$($SLAVE -BN -e "select master_pos_wait('$master_binlog', $master_pos,60)") | ||||||||||||||
| S_READY=$($SLAVE -BN -e "select {{.MasterPosWaitFunc}}('$master_binlog', $master_pos,60)") | ||||||||||||||
| # master_pos_wait can return 0 or a positive number for successful replication | ||||||||||||||
| # Any result that is not NULL or -1 is acceptable | ||||||||||||||
| if [ "$S_READY" != "-1" -a "$S_READY" != "NULL" ] | ||||||||||||||
|
Comment on lines
102
to
104
|
||||||||||||||
| # master_pos_wait can return 0 or a positive number for successful replication | |
| # Any result that is not NULL or -1 is acceptable | |
| if [ "$S_READY" != "-1" -a "$S_READY" != "NULL" ] | |
| # The position wait function ({{.MasterPosWaitFunc}}) can return 0 or a positive number for successful replication | |
| # Any result that is not NULL or -1 is acceptable | |
| if [ "$S_READY" != "-1" -a "$SREADY" != "NULL" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code populates replication commands into the
datamap. It is repeated inCreateFanInReplicationand with variations insandbox/replication.go. To improve maintainability and reduce duplication, you could use a loop. This would also make it easier to add new commands in the future.