Skip to content

feat: add MySQL 8.4-specific replication and group replication templates (#60)#62

Merged
renecannao merged 1 commit intomasterfrom
worktree-agent-a4f95dc2
Apr 2, 2026
Merged

feat: add MySQL 8.4-specific replication and group replication templates (#60)#62
renecannao merged 1 commit intomasterfrom
worktree-agent-a4f95dc2

Conversation

@renecannao
Copy link
Copy Markdown

@renecannao renecannao commented Apr 2, 2026

Summary

Dedicated templates for MySQL 8.4+ that use the modern replication syntax, eliminating deprecation warnings.

New templates:

  • repl_crash_safe_options84.gotxt — omits removed variables (master-info-repository, relay-log-info-repository)
  • init_slaves_84.gotxt — uses CHANGE REPLICATION SOURCE TO syntax
  • group_repl_options84.gotxt — drops transaction_write_set_extraction (removed in 8.4), uses log_replica_updates=ON
  • init_nodes84.gotxt — group replication init with 8.4+ variable names

Version-based selection:

  • Group replication: 8.4+ templates selected automatically
  • Standard replication: 8.0.23+ uses SOURCE_AUTO_POSITION
  • Multi-source replication (fan-in, all-masters): 8.4+ crash-safe options
  • PXC: 8.4+ crash-safe options
  • Single with GTID: 8.4+ crash-safe options

Older MySQL versions (5.7, 8.0) continue using original templates unchanged.

Closes #60

Test Plan

  • Build succeeds
  • Existing sandbox tests pass (pre-existing catalog failure unrelated)
  • Integration test: deploy replication with 8.4 — no deprecation warnings in error log
  • Integration test: deploy group replication with 8.4 — clean startup

Summary by CodeRabbit

  • New Features
    • Added MySQL 8.4+ support with version-aware sandbox initialization and group replication templates
    • Replication configuration now uses MySQL 8.4+ compatible syntax and crash-safe settings for improved reliability

Add dedicated templates for MySQL 8.4+ that eliminate deprecation warnings
from removed/renamed variables:
- repl_crash_safe_options84.gotxt: omits master-info-repository and
  relay-log-info-repository (removed in 8.4), keeps relay-log-recovery=on
- group_repl_options84.gotxt: omits transaction_write_set_extraction
  (removed in 8.4) and uses log_replica_updates unconditionally
- init_slaves_84.gotxt: documents 8.4+ CHANGE REPLICATION SOURCE TO syntax
- init_nodes84.gotxt: group replication init using 8.4+ replication commands

Update replication.go to use SOURCE_AUTO_POSITION instead of
MASTER_AUTO_POSITION for MySQL 8.0.23+, and select the appropriate
init_slaves template based on version. Update group_replication.go,
multi-source-replication.go, pxc_replication.go, and cmd/single.go to
select the 8.4-specific crash-safe and group options templates when the
MySQL version is >= 8.4.0.
Copilot AI review requested due to automatic review settings April 2, 2026 06:48
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

Adds MySQL 8.4-specific replication and connection templates to support syntax changes in MySQL 8.4. Introduces new template constants, template files, and version-aware selection logic across single, group, master-slave, multi-source, and PXC replication topologies. When sandbox version >= MinimumResetBinaryLogsVersion, the code now selects 8.4-specific template variants.

Changes

Cohort / File(s) Summary
Template Name Constants
globals/template_names.go
Added four new exported template constants: TmplInitNodes84, TmplGroupReplOptions84, TmplInitSlaves84, TmplReplCrashSafeOptions84 with corresponding string identifiers. Reformatted alignment of existing constant declarations without changing values.
Single Replication Templates
cmd/single.go, sandbox/templates.go, sandbox/templates/single/repl_crash_safe_options84.gotxt
Updated fillSandboxDefinition to conditionally select TmplReplCrashSafeOptions84 for MySQL 8.4+ versions. Registered new TmplReplCrashSafeOptions84 template with 8.4-compatible configuration excluding removed variables.
Group Replication Templates
sandbox/group_replication.go, sandbox/group_templates.go, sandbox/templates/group/*
Modified CreateGroupReplication to select version-appropriate init nodes and group replication option templates. Added GroupTemplates entries for TmplInitNodes84 and TmplGroupReplOptions84 with corresponding template files containing 8.4-specific syntax and placeholders.
Master-Slave Replication
sandbox/replication.go, sandbox/repl_templates.go, sandbox/templates/replication/init_slaves_84.gotxt
Updated CreateMasterSlaveReplication to select TmplInitSlaves84 for versions >= MinimumChangeReplicationSourceVersion using CHANGE REPLICATION SOURCE TO syntax. Added AUTO_POSITION version-aware handling and registered new template with 8.4 replication initialization logic.
Multi-Source Replication
sandbox/multi-source-replication.go
Updated CreateAllMastersReplication and CreateFanInReplication to conditionally select TmplReplCrashSafeOptions84 based on version check, replacing prior inverted boolean logic with direct template selection on both branches.
PXC Replication
sandbox/pxc_replication.go
Updated CreatePxcReplication to append TmplReplCrashSafeOptions84 when version >= MinimumResetBinaryLogsVersion, replacing inverted conditional logic with version-aware template routing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Eight-point-four brings new replication ways,
With templates fresh for modern MySQL days,
Version checks guide us left or right,
Each topology now shines so bright! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements core template additions and version-based selection logic from #60. Three required templates are implemented; connection_info_sql_84.gotxt and load_grants_cluster.gotxt are not included. Add missing required templates: connection_info_sql_84.gotxt and load_grants_cluster.gotxt, as specified in #60 requirements.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the primary change: addition of MySQL 8.4-specific replication and group replication templates.
Out of Scope Changes check ✅ Passed All changes align with #60 requirements for MySQL 8.4+ template support. Code updates properly select version-appropriate templates and maintain backward compatibility.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-agent-a4f95dc2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for MySQL 8.4+ by implementing version-aware template selection for single, group, and multi-source replication. It addresses the removal of deprecated parameters like master-info-repository and transaction_write_set_extraction while introducing new syntax such as SOURCE_AUTO_POSITION. The review feedback highlights several opportunities to improve efficiency and maintainability by refactoring duplicated version checks and moving constant checks outside of loops.

sd.ReplCrashSafeOptions = sandbox.SingleTemplates[globals.TmplReplCrashSafeOptions].Contents
// Use 8.4+ crash-safe options template (no deprecated master-info-repository)
crashSafeTmpl := globals.TmplReplCrashSafeOptions
isMySQL84, _ := common.GreaterOrEqualVersion(sd.Version, globals.MinimumResetBinaryLogsVersion)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This version check and the subsequent template selection logic (lines 428-432) are identical to the block at lines 404-408. Consider refactoring this logic into a common variable or a helper function to improve maintainability and avoid duplication.

useReplicaUpdates, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumShowReplicaStatusVersion)
useNoWriteSetExtraction, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumNoWriteSetExtractionVersion)
// Use 8.4+ group replication options template when applicable
useMySQL84GroupOptions, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumResetBinaryLogsVersion)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This version check is redundant because it was already performed at line 293 (isMySQL84). Additionally, performing this check inside the loop is inefficient as sandboxDef.Version remains constant across iterations.

Suggested change
useMySQL84GroupOptions, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumResetBinaryLogsVersion)
useMySQL84GroupOptions := isMySQL84


// Select the appropriate init_slaves template based on MySQL version
initSlavesTemplate := globals.TmplInitSlaves
useNewSourceSyntax, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumChangeReplicationSourceVersion)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This version check is redundant as it was already performed at line 227 (useSourceAutoPosition). Reusing the existing variable improves readability and efficiency.

Suggested change
useNewSourceSyntax, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumChangeReplicationSourceVersion)
useNewSourceSyntax := useSourceAutoPosition

// master-info-repository and relay-log-info-repository removed in 8.4+
skipCrashSafeOpts, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumResetBinaryLogsVersion)
if !skipCrashSafeOpts {
isMySQL84pxc, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumResetBinaryLogsVersion)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This version check is performed inside a loop (starting at line 249), but sandboxDef.Version is constant. Moving this check outside the loop would be more efficient.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
sandbox/templates/replication/init_slaves_84.gotxt (1)

28-31: Inconsistent indentation and shell convention for exit code comparison.

Two minor issues:

  1. Line 30 lacks indentation within the if block, making the script harder to read.
  2. The exit code comparison uses string equality ("0") instead of numeric comparison (-eq 0), which is unconventional in shell scripts.
♻️ Suggested fix for formatting and convention
-	if [ "$exit_code" == "0" ]
+	if [ "$exit_code" -eq 0 ]
 	then
-rm -f ./post_initialization
+		rm -f ./post_initialization
 	fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sandbox/templates/replication/init_slaves_84.gotxt` around lines 28 - 31, The
if-statement comparing exit_code is using string equality and the rm command is
not indented; update the conditional in the block that references the variable
exit_code to use numeric comparison (e.g., -eq 0) instead of "==" "0", and
indent the rm -f ./post_initialization line inside the if body (the block
controlling removal of post_initialization) so the script follows standard shell
conventions and consistent formatting.
sandbox/group_replication.go (1)

348-365: Consider reusing the isMySQL84 variable computed earlier.

The version check at line 349 (useMySQL84GroupOptions) duplicates the check at line 293 (isMySQL84). Consider reusing isMySQL84 to avoid redundant version comparisons.

♻️ Suggested consolidation
-		// Use 8.4+ group replication options template when applicable
-		useMySQL84GroupOptions, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumResetBinaryLogsVersion)
...
 		groupReplOptionsTmpl := globals.TmplGroupReplOptions
-		if useMySQL84GroupOptions {
+		if isMySQL84 {
 			groupReplOptionsTmpl = globals.TmplGroupReplOptions84
 		}
...
-		if useMySQL84GroupOptions {
+		if isMySQL84 {
 			// relay-log-recovery is still valid; use the 8.4-specific template
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sandbox/group_replication.go` around lines 348 - 365, The code duplicates a
version check by computing useMySQL84GroupOptions instead of reusing the earlier
isMySQL84; replace the second check with the existing isMySQL84 variable (remove
the call to common.GreaterOrEqualVersion for sandboxDef.Version) and use
isMySQL84 when selecting groupReplOptionsTmpl (affecting variables
useMySQL84GroupOptions, groupReplOptionsTmpl and the branch that sets
TmplGroupReplOptions84) so the template selection uses the previously computed
isMySQL84 boolean.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@sandbox/repl_templates.go`:
- Around line 141-145: The template globals.TmplInitSlaves84 is described as
MySQL 8.4+ but the selection logic in replication.go currently uses
MinimumChangeReplicationSourceVersion (8.0.23); update that selection to use
MinimumResetBinaryLogsVersion (8.4.0) instead so TmplInitSlaves84 is only
applied for MySQL versions that support the 8.4+ syntax (mirror the approach
used for TmplInitNodes84 in sandbox/group_replication.go).

In `@sandbox/templates/group/init_nodes84.gotxt`:
- Line 13: The template hardcodes replication credentials ('rsandbox') in the
user_cmd string; update the construction of user_cmd (the line building user_cmd
that uses .ChangeMasterTo, .MasterUserParam, .MasterPasswordParam,
.ChangeMasterExtra and FOR CHANNEL 'group_replication_recovery') to inject the
configured replication username and password fields (e.g. .RplUser and
.RplPassword) instead of the literal 'rsandbox', preserving existing
quoting/escaping and placement of .MasterUserParam/.MasterPasswordParam so
customized RplUser/RplPassword values are used during group replication init.

---

Nitpick comments:
In `@sandbox/group_replication.go`:
- Around line 348-365: The code duplicates a version check by computing
useMySQL84GroupOptions instead of reusing the earlier isMySQL84; replace the
second check with the existing isMySQL84 variable (remove the call to
common.GreaterOrEqualVersion for sandboxDef.Version) and use isMySQL84 when
selecting groupReplOptionsTmpl (affecting variables useMySQL84GroupOptions,
groupReplOptionsTmpl and the branch that sets TmplGroupReplOptions84) so the
template selection uses the previously computed isMySQL84 boolean.

In `@sandbox/templates/replication/init_slaves_84.gotxt`:
- Around line 28-31: The if-statement comparing exit_code is using string
equality and the rm command is not indented; update the conditional in the block
that references the variable exit_code to use numeric comparison (e.g., -eq 0)
instead of "==" "0", and indent the rm -f ./post_initialization line inside the
if body (the block controlling removal of post_initialization) so the script
follows standard shell conventions and consistent formatting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bf18a2cd-2e0f-4938-8093-18375d45ffaf

📥 Commits

Reviewing files that changed from the base of the PR and between 437c392 and ddbfd01.

📒 Files selected for processing (13)
  • cmd/single.go
  • globals/template_names.go
  • sandbox/group_replication.go
  • sandbox/group_templates.go
  • sandbox/multi-source-replication.go
  • sandbox/pxc_replication.go
  • sandbox/repl_templates.go
  • sandbox/replication.go
  • sandbox/templates.go
  • sandbox/templates/group/group_repl_options84.gotxt
  • sandbox/templates/group/init_nodes84.gotxt
  • sandbox/templates/replication/init_slaves_84.gotxt
  • sandbox/templates/single/repl_crash_safe_options84.gotxt

Comment on lines +141 to +145
globals.TmplInitSlaves84: TemplateDesc{
Description: "Initialize slaves after deployment (MySQL 8.4+ syntax)",
Notes: "Uses CHANGE REPLICATION SOURCE TO and SOURCE_AUTO_POSITION",
Contents: initSlaves84Template,
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify version constant values and usage consistency

echo "=== Version constant definitions ==="
rg -n 'Minimum(ChangeReplicationSource|ResetBinaryLogs)Version' --type=go -A1

echo ""
echo "=== Usage in template selection ==="
rg -n 'TmplInitSlaves84|TmplInitNodes84' --type=go -B3 -A1

Repository: ProxySQL/dbdeployer

Length of output: 4849


Fix version threshold for template selection to match 8.4+ syntax requirement.

The template is named and described for MySQL 8.4+ syntax, but is selected using MinimumChangeReplicationSourceVersion (8.0.23) instead of MinimumResetBinaryLogsVersion (8.4.0). This inconsistency conflicts with the "MySQL 8.4+ syntax" description and differs from the parallel TmplInitNodes84 template in sandbox/group_replication.go, which correctly uses MinimumResetBinaryLogsVersion for 8.4-specific features.

Update sandbox/replication.go (around line 508) to select TmplInitSlaves84 using MinimumResetBinaryLogsVersion instead, ensuring the template is only applied to MySQL versions that actually support its declared 8.4+ syntax.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sandbox/repl_templates.go` around lines 141 - 145, The template
globals.TmplInitSlaves84 is described as MySQL 8.4+ but the selection logic in
replication.go currently uses MinimumChangeReplicationSourceVersion (8.0.23);
update that selection to use MinimumResetBinaryLogsVersion (8.4.0) instead so
TmplInitSlaves84 is only applied for MySQL versions that support the 8.4+ syntax
(mirror the approach used for TmplInitNodes84 in sandbox/group_replication.go).

[ -z "$SLEEP_TIME" ] && SLEEP_TIME=1
{{range .Nodes}}
user_cmd='{{.ResetMasterCmd}};'
user_cmd="$user_cmd {{.ChangeMasterTo}} {{.MasterUserParam}}='rsandbox', {{.MasterPasswordParam}}='rsandbox' {{.ChangeMasterExtra}} FOR CHANNEL 'group_replication_recovery';"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Hardcoded replication credentials ignore configured values.

Line 13 always uses 'rsandbox' credentials, which can fail group replication init when RplUser/RplPassword are customized.

Suggested fix
-    user_cmd="$user_cmd {{.ChangeMasterTo}} {{.MasterUserParam}}='rsandbox', {{.MasterPasswordParam}}='rsandbox' {{.ChangeMasterExtra}} FOR CHANNEL 'group_replication_recovery';"
+    user_cmd="$user_cmd {{.ChangeMasterTo}} {{.MasterUserParam}}='{{.RplUser}}', {{.MasterPasswordParam}}='{{.RplPassword}}' {{.ChangeMasterExtra}} FOR CHANNEL 'group_replication_recovery';"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
user_cmd="$user_cmd {{.ChangeMasterTo}} {{.MasterUserParam}}='rsandbox', {{.MasterPasswordParam}}='rsandbox' {{.ChangeMasterExtra}} FOR CHANNEL 'group_replication_recovery';"
user_cmd="$user_cmd {{.ChangeMasterTo}} {{.MasterUserParam}}='{{.RplUser}}', {{.MasterPasswordParam}}='{{.RplPassword}}' {{.ChangeMasterExtra}} FOR CHANNEL 'group_replication_recovery';"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sandbox/templates/group/init_nodes84.gotxt` at line 13, The template
hardcodes replication credentials ('rsandbox') in the user_cmd string; update
the construction of user_cmd (the line building user_cmd that uses
.ChangeMasterTo, .MasterUserParam, .MasterPasswordParam, .ChangeMasterExtra and
FOR CHANNEL 'group_replication_recovery') to inject the configured replication
username and password fields (e.g. .RplUser and .RplPassword) instead of the
literal 'rsandbox', preserving existing quoting/escaping and placement of
.MasterUserParam/.MasterPasswordParam so customized RplUser/RplPassword values
are used during group replication init.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds MySQL 8.4+ template variants for replication and group replication so deployments can use newer syntax/variables and avoid deprecation warnings, while keeping older MySQL versions on existing templates.

Changes:

  • Introduces new 8.4+ templates for crash-safe replication options, slave init, group init, and group replication options.
  • Embeds/registers new templates and adds version-based selection in replication/group/PXC/multi-source/single flows.
  • Updates GTID auto-position option selection to use SOURCE_AUTO_POSITION starting with MySQL 8.0.23.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
sandbox/templates/single/repl_crash_safe_options84.gotxt New crash-safe options template for MySQL 8.4+ (drops removed vars).
sandbox/templates/replication/init_slaves_84.gotxt New slave init script template labeled for 8.4+ syntax.
sandbox/templates/group/init_nodes84.gotxt New group replication init script template for 8.4+.
sandbox/templates/group/group_repl_options84.gotxt New group replication options template for 8.4+ variable set.
sandbox/templates.go Embeds/registers repl_crash_safe_options84.
sandbox/replication.go Adds SOURCE_AUTO_POSITION gating and selects init-slaves template by version.
sandbox/repl_templates.go Embeds/registers init_slaves_84.
sandbox/pxc_replication.go Uses 8.4 crash-safe options template for PXC at 8.4+.
sandbox/multi-source-replication.go Uses 8.4 crash-safe options template for fan-in/all-masters at 8.4+.
sandbox/group_templates.go Embeds/registers group init/options 8.4 templates.
sandbox/group_replication.go Selects 8.4+ group init/options/crash-safe templates by version.
globals/template_names.go Adds new template name constants for the 8.4 variants.
cmd/single.go Selects 8.4 crash-safe options template for single sandboxes when applicable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +227 to +234
useSourceAutoPosition, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumChangeReplicationSourceVersion)
if useSourceAutoPosition {
masterAutoPosition = ", SOURCE_AUTO_POSITION=1"
logger.Printf("Adding SOURCE_AUTO_POSITION to slaves setup\n")
} else {
masterAutoPosition = ", MASTER_AUTO_POSITION=1"
logger.Printf("Adding MASTER_AUTO_POSITION to slaves setup\n")
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

New code uses common.GreaterOrEqualVersion(), which is marked DEPRECATED (common/checks.go notes to use GreaterOrEqualVersionList + flavors or common.HasCapability). Consider switching this version gate to the non-deprecated helpers to avoid adding more deprecated call sites (and handle/propagate the comparison error instead of discarding it).

Copilot uses AI. Check for mistakes.
Comment on lines +506 to +509
// Select the appropriate init_slaves template based on MySQL version
initSlavesTemplate := globals.TmplInitSlaves
useNewSourceSyntax, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumChangeReplicationSourceVersion)
if useNewSourceSyntax {
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The init-slaves template selection uses MinimumChangeReplicationSourceVersion (8.0.23) to choose globals.TmplInitSlaves84. Either the template/name should reflect that it targets 8.0.23+ (not 8.4+), or the selection should use the 8.4 gate if the intent is truly “84+”. Leaving this as-is is confusing and makes future maintenance harder.

Suggested change
// Select the appropriate init_slaves template based on MySQL version
initSlavesTemplate := globals.TmplInitSlaves
useNewSourceSyntax, _ := common.GreaterOrEqualVersion(sandboxDef.Version, globals.MinimumChangeReplicationSourceVersion)
if useNewSourceSyntax {
// Select the appropriate init_slaves template based on MySQL version.
// TmplInitSlaves84 is intended for MySQL 8.4+; earlier versions use the legacy template.
initSlavesTemplate := globals.TmplInitSlaves
useInitSlaves84, _ := common.GreaterOrEqualVersion(sandboxDef.Version, "8.4.0")
if useInitSlaves84 {

Copilot uses AI. Check for mistakes.

# Don't use directly.
# This script is called by 'start_all' when needed
# Uses MySQL 8.4+ replication syntax (CHANGE REPLICATION SOURCE TO)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This header says the script is for “MySQL 8.4+”, but in code it’s selected starting at 8.0.23 (MinimumChangeReplicationSourceVersion). Please update the comment (and/or the template name) so it matches the actual version range where it’s used.

Suggested change
# Uses MySQL 8.4+ replication syntax (CHANGE REPLICATION SOURCE TO)
# Uses MySQL 8.0.23+ replication syntax (CHANGE REPLICATION SOURCE TO)

Copilot uses AI. Check for mistakes.
TmplInitNodes84 = "init_nodes84"
TmplGroupReplOptions84 = "group_repl_options84"

// MySQL 8.4+ specific templates
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The “MySQL 8.4+ specific templates” section includes TmplInitSlaves84, but current selection logic uses it for >= 8.0.23. Please adjust the comment/grouping (or rename the template) so this list doesn’t misrepresent the version boundary.

Suggested change
// MySQL 8.4+ specific templates
// MySQL 8.0.23+ specific templates

Copilot uses AI. Check for mistakes.
Comment on lines +403 to +409
// Use 8.4+ crash-safe options template (no deprecated master-info-repository)
crashSafeTmpl := globals.TmplReplCrashSafeOptions
isMySQL84, _ := common.GreaterOrEqualVersion(sd.Version, globals.MinimumResetBinaryLogsVersion)
if isMySQL84 {
crashSafeTmpl = globals.TmplReplCrashSafeOptions84
}
sd.ReplCrashSafeOptions = sandbox.SingleTemplates[crashSafeTmpl].Contents
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This adds a new common.GreaterOrEqualVersion() call to gate 8.4-specific behavior. Since GreaterOrEqualVersion is deprecated, prefer common.HasCapability (if an appropriate capability exists) or VersionToList + GreaterOrEqualVersionList, and avoid ignoring the returned error.

Copilot uses AI. Check for mistakes.
Comment on lines +427 to +433
// Use 8.4+ crash-safe options template (no deprecated master-info-repository)
crashSafeTmpl := globals.TmplReplCrashSafeOptions
isMySQL84, _ := common.GreaterOrEqualVersion(sd.Version, globals.MinimumResetBinaryLogsVersion)
if isMySQL84 {
crashSafeTmpl = globals.TmplReplCrashSafeOptions84
}
sd.ReplCrashSafeOptions = sandbox.SingleTemplates[crashSafeTmpl].Contents
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

Same as above: this introduces another common.GreaterOrEqualVersion() call (deprecated) for 8.4 gating. Please use the non-deprecated helpers and handle the comparison error instead of discarding it.

Copilot uses AI. Check for mistakes.
@renecannao renecannao merged commit a184354 into master Apr 2, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add MySQL 8.4-specific replication and connection templates

2 participants