-
Notifications
You must be signed in to change notification settings - Fork 2
Fix group replication and multi-source for MySQL 8.4+ #50
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -113,7 +113,10 @@ func CreateAllMastersReplication(sandboxDef SandboxDef, origin string, nodes int | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| sandboxDef.GtidOptions = SingleTemplates[globals.TmplGtidOptions57].Contents | ||||||||||||||||||
| sandboxDef.ReplCrashSafeOptions = SingleTemplates[globals.TmplReplCrashSafeOptions].Contents | ||||||||||||||||||
| skipCrashSafeOpts, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumResetBinaryLogsVersion) | ||||||||||||||||||
| if !skipCrashSafeOpts { | ||||||||||||||||||
| sandboxDef.ReplCrashSafeOptions = SingleTemplates[globals.TmplReplCrashSafeOptions].Contents | ||||||||||||||||||
|
||||||||||||||||||
| sandboxDef.ReplCrashSafeOptions = SingleTemplates[globals.TmplReplCrashSafeOptions].Contents | |
| sandboxDef.ReplCrashSafeOptions = SingleTemplates[globals.TmplReplCrashSafeOptions].Contents | |
| } else { | |
| // For versions >= MinimumResetBinaryLogsVersion (e.g. 8.4+), ensure that any | |
| // pre-existing crash-safe replication options are cleared so they are not | |
| // written into my.cnf where they could break server startup. | |
| sandboxDef.ReplCrashSafeOptions = "" |
Copilot
AI
Mar 24, 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.
Same issue as above: when skipCrashSafe2 is true (8.4+), sandboxDef.ReplCrashSafeOptions is not cleared, so any pre-populated crash-safe options may still be emitted into configs and trigger 8.4+ startup failures. Set sandboxDef.ReplCrashSafeOptions = "" in the skip branch to ensure removed options aren’t carried over.
| sandboxDef.ReplCrashSafeOptions = SingleTemplates[globals.TmplReplCrashSafeOptions].Contents | |
| sandboxDef.ReplCrashSafeOptions = SingleTemplates[globals.TmplReplCrashSafeOptions].Contents | |
| } else { | |
| sandboxDef.ReplCrashSafeOptions = "" |
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.
The variable name skipCrashSafe2 is a bit confusing. Since this variable is local to the CreateFanInReplication function, you could reuse the name skipCrashSafeOpts as used in CreateAllMastersReplication for consistency.
| skipCrashSafe2, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumResetBinaryLogsVersion) | |
| if !skipCrashSafe2 { | |
| sandboxDef.ReplCrashSafeOptions = SingleTemplates[globals.TmplReplCrashSafeOptions].Contents | |
| } | |
| skipCrashSafeOpts, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumResetBinaryLogsVersion) | |
| if !skipCrashSafeOpts { | |
| sandboxDef.ReplCrashSafeOptions = SingleTemplates[globals.TmplReplCrashSafeOptions].Contents | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -225,7 +225,12 @@ func CreatePxcReplication(sandboxDef SandboxDef, origin string, nodes int, maste | |||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if !skipLogSlaveUpdates { | ||||||||||||||||||||||||||
| sandboxDef.ReplOptions = fmt.Sprintf("%s\nlog_slave_updates=ON\n", sandboxDef.ReplOptions) | ||||||||||||||||||||||||||
| useReplicaUpdates, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumShowReplicaStatusVersion) | ||||||||||||||||||||||||||
| if useReplicaUpdates { | ||||||||||||||||||||||||||
| sandboxDef.ReplOptions = fmt.Sprintf("%s\nlog_replica_updates=ON\n", sandboxDef.ReplOptions) | ||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||
| sandboxDef.ReplOptions = fmt.Sprintf("%s\nlog_slave_updates=ON\n", sandboxDef.ReplOptions) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+228
to
+233
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. To improve maintainability and reduce code duplication, you can determine the option name first and then use it in a single
Suggested change
|
||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| baseReplicationOptions := sandboxDef.ReplOptions | ||||||||||||||||||||||||||
| var groupCommunication string = "gcomm://" | ||||||||||||||||||||||||||
|
|
@@ -322,7 +327,11 @@ func CreatePxcReplication(sandboxDef SandboxDef, origin string, nodes int, maste | |||||||||||||||||||||||||
| sandboxDef.ReplOptions = baseReplicationOptions + fmt.Sprintf("\n%s\n", pxcFilledTemplate) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| sandboxDef.ReplOptions += fmt.Sprintf("\n%s\n", SingleTemplates[globals.TmplGtidOptions57].Contents) | ||||||||||||||||||||||||||
| sandboxDef.ReplOptions += fmt.Sprintf("\n%s\n", SingleTemplates[globals.TmplReplCrashSafeOptions].Contents) | ||||||||||||||||||||||||||
| // master-info-repository and relay-log-info-repository removed in 8.4+ | ||||||||||||||||||||||||||
| skipCrashSafeOpts, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumResetBinaryLogsVersion) | ||||||||||||||||||||||||||
| if !skipCrashSafeOpts { | ||||||||||||||||||||||||||
| sandboxDef.ReplOptions += fmt.Sprintf("\n%s\n", SingleTemplates[globals.TmplReplCrashSafeOptions].Contents) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+330
to
+334
|
||||||||||||||||||||||||||
| // 8.0.11 | ||||||||||||||||||||||||||
| isMinimumMySQLXDefault, err := common.HasCapability(sandboxDef.Flavor, common.MySQLXDefault, sandboxDef.Version) | ||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ func replicationCommands(version string) map[string]string { | |
| "StartReplica": "START SLAVE", | ||
| "StopReplica": "STOP SLAVE", | ||
| "ResetReplica": "RESET SLAVE", | ||
| "ResetMasterCmd": "reset master", | ||
| "MasterPosWaitFunc": "master_pos_wait", | ||
| "MasterHostParam": "master_host", | ||
| "MasterPortParam": "master_port", | ||
|
|
@@ -67,6 +68,11 @@ func replicationCommands(version string) map[string]string { | |
| cmds["ShowMasterStatus"] = "show binary log status" | ||
| } | ||
|
|
||
| useResetBinaryLogs, _ := common.GreaterOrEqualVersion(version, globals.MinimumResetBinaryLogsVersion) | ||
| if useResetBinaryLogs { | ||
| cmds["ResetMasterCmd"] = "RESET BINARY LOGS AND GTIDS" | ||
| } | ||
|
Comment on lines
+71
to
+74
|
||
|
|
||
| return cmds | ||
| } | ||
|
|
||
|
|
@@ -269,6 +275,7 @@ func CreateMasterSlaveReplication(sandboxDef SandboxDef, origin string, nodes in | |
| "StartReplica": replCmds["StartReplica"], | ||
| "StopReplica": replCmds["StopReplica"], | ||
| "ResetReplica": replCmds["ResetReplica"], | ||
| "ResetMasterCmd": replCmds["ResetMasterCmd"], | ||
| "MasterPosWaitFunc": replCmds["MasterPosWaitFunc"], | ||
| "MasterHostParam": replCmds["MasterHostParam"], | ||
| "MasterPortParam": replCmds["MasterPortParam"], | ||
|
|
@@ -376,6 +383,7 @@ func CreateMasterSlaveReplication(sandboxDef SandboxDef, origin string, nodes in | |
| "MasterUserParam": replCmds["MasterUserParam"], | ||
| "MasterPasswordParam": replCmds["MasterPasswordParam"], | ||
| "MasterPosWaitFunc": replCmds["MasterPosWaitFunc"], | ||
| "ResetMasterCmd": replCmds["ResetMasterCmd"], | ||
| }) | ||
| sandboxDef.LoadGrants = false | ||
| sandboxDef.Prompt = fmt.Sprintf("%s%d", slaveLabel, i) | ||
|
|
@@ -446,6 +454,7 @@ func CreateMasterSlaveReplication(sandboxDef SandboxDef, origin string, nodes in | |
| "MasterUserParam": replCmds["MasterUserParam"], | ||
| "MasterPasswordParam": replCmds["MasterPasswordParam"], | ||
| "MasterPosWaitFunc": replCmds["MasterPosWaitFunc"], | ||
| "ResetMasterCmd": replCmds["ResetMasterCmd"], | ||
| } | ||
| logger.Printf("Defining replication node data: %v\n", stringMapToJson(dataSlave)) | ||
| logger.Printf("Create slave script %d\n", i) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,12 @@ fi | |
| is_master=$(ls data | grep 'mysql-bin') | ||
| if [ -n "$is_master" ] | ||
| then | ||
| ./use -e 'reset master' | ||
| minimum_version_reset_binary_logs="008004000" | ||
| if [[ "v$sortable_version" > "v$minimum_version_reset_binary_logs" ]] || [[ "v$sortable_version" == "v$minimum_version_reset_binary_logs" ]]; then | ||
| ./use -e 'RESET BINARY LOGS AND GTIDS' | ||
| else | ||
| ./use -e 'reset master' | ||
| fi | ||
|
Comment on lines
+46
to
+51
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. This logic for choosing the
Since changing the Go code to pass the version is out of scope for this file, I'll suggest simplifying the shell logic for now.
Comment on lines
+46
to
+51
|
||
| fi | ||
|
|
||
| ./stop | ||
|
|
||
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.
MinimumResetBinaryLogsVersionis being used here as the cutoff for skipping crash-safe replication options (becausemaster-info-repository/relay-log-info-repositorywere removed in 8.4+). Since the constant name describes a different behavior (reset binary logs), this coupling makes future maintenance harder (e.g., if one cutoff changes independently). Consider introducing a dedicated version constant for the removal of crash-safe repository options, and use that here.