Skip to content

Feat/migrate pxc to mgr#123

Open
SuJinpei wants to merge 13 commits intomainfrom
feat/migrate-pxc-to-mgr
Open

Feat/migrate pxc to mgr#123
SuJinpei wants to merge 13 commits intomainfrom
feat/migrate-pxc-to-mgr

Conversation

@SuJinpei
Copy link
Contributor

@SuJinpei SuJinpei commented Jan 30, 2026

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive end-to-end MySQL 5.7→8.0 migration guide covering planning, prerequisites, environment setup, schema compatibility, charset conversion, GTID/replication considerations, streaming export/import, user/privilege migration, verification, cutover, monitoring, rollback and troubleshooting with practical commands and examples.
    • Introduced user-facing migration and verification scripts with progress/error indicators, secure secret handling, minimal configuration, rollback options, automated verification steps, and a production-readiness checklist.

✏️ Tip: You can customize this high-level summary in your review settings.

@SuJinpei SuJinpei requested a review from a team January 30, 2026 06:41
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a comprehensive MySQL 5.7 → 8.0 migration guide and three automation scripts implementing a mysqldump-based streaming workflow: prerequisites, schema/charset/GTID/auth inspections, provisioning, data/users migration, verification, rollback, troubleshooting, and an appendix with script usage and sample outputs. (≤50 words)

Changes

Cohort / File(s) Summary
Migration Guide & Scripts
docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md
New end-to-end migration document detailing prereqs, Step 1–7 execution (schema analysis, charset/collation fixes, target provisioning, data/user migration, verification, post-migration tuning, cutover), GTID/MGR handling, PXC vs MGR notes, rollback/disaster plans, troubleshooting, production-readiness guidance, and an Appendix with three scripts (00-pre-migration-check.sh, 01-migrate-all.sh, 02-verify-migration.sh) including usage, outputs, and error handling.

Sequence Diagram(s)

sequenceDiagram
  participant Engineer
  participant Secrets as Secret Store
  participant Scripts as Migration Scripts (bash)
  participant SourceDB as MySQL 5.7
  participant TargetDB as MySQL 8.0

  Engineer->>Secrets: retrieve credentials
  Engineer->>Scripts: run 00-pre-migration-check.sh
  Scripts->>SourceDB: inspect schema, users, GTID, charsets
  Scripts-->>Engineer: report compatibility issues
  Engineer->>Scripts: run 01-migrate-all.sh (streaming mysqldump)
  Scripts->>SourceDB: stream data (mysqldump)
  Scripts->>TargetDB: apply stream (mysql import)
  Scripts->>TargetDB: adjust auth plugins and GTID handling
  Engineer->>Scripts: run 02-verify-migration.sh
  Scripts-->>Engineer: verification results (objects, users, row counts)
  Engineer->>TargetDB: perform cutover / monitoring
  Note over SourceDB,TargetDB: Optional rollback if verification fails
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I hopped through dumps and charset streams,
Checked GTIDs, users, and migration beams,
Three scripts in paw, logs shining bright,
I verified rows through day and night,
A rabbit cheers — the cutover's light.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title 'Feat/migrate pxc to mgr' is vague and does not clearly describe the actual content being added—a comprehensive MySQL 5.7 to 8.0 migration guide. Change the title to something more descriptive, such as 'Add MySQL 5.7 to 8.0 migration guide for PXC to MGR transitions' to better reflect the primary change of adding documentation.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/migrate-pxc-to-mgr

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
Contributor

@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: 6

🤖 Fix all issues with AI agents
In `@docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md`:
- Around line 48-56: The markdown tables in this document use the compact pipe
style and violate MD060; update each table (e.g., the test case table that
contains rows like "TC-01...") to the spaced pipe style by adding a single space
before and after each '|' delimiter in header, separator, and data rows so pipes
are surrounded by spaces (apply the same change for all other tables flagged
such as those around the ranges referenced in the review comment).
- Around line 223-248: The HA guidance and the example YAML disagree: the
bullets recommend 3 replicas but the Mysql spec under spec.mgr sets members: 1
(and router replicas are 1 elsewhere). Either update the YAML to demonstrate HA
by setting spec.mgr.members: 3 and ensure any router replica settings are also
increased to 3, or explicitly state in the bullet list that the provided YAML is
a single-node test/staging example and not suitable for production; update
references to spec.mgr, members, mgr, and any router replica settings to keep
text and YAML consistent.
- Line 17: The sentence "MySQL 5.7 End of Life (EOL) is approaching in October
2023" should be changed to past tense and reflect that the EOL date has already
passed; locate that exact sentence in the doc and replace it with wording such
as "MySQL 5.7 reached End of Life (EOL) in October 2023" and adjust surrounding
verbs (e.g., "must upgrade" → "should upgrade" or "need to have upgraded") to
maintain tense consistency in the paragraph and keep the rest of the migration
considerations unchanged.
- Around line 585-611: The bolded lines "Method 1: Using mysqldump
(Recommended)" and "Method 2: Manual Export with CREATE USER Statements" are
styled as emphasis but should be actual headings for TOC/navigation; replace the
bold markup with appropriate Markdown heading syntax (e.g., "## Method 1: Using
mysqldump (Recommended)" and "## Method 2: Manual Export with CREATE USER
Statements") so the sections are recognized as headings and included in the
document structure, and ensure any adjacent inline bold text remains unchanged.
- Around line 1216-1274: The fenced code blocks showing MySQL error outputs
(e.g., the blocks containing "ERROR 3546 (HY000) ...", "ERROR 1366 (HY000):
Incorrect string value", and "ERROR 1449 (HY000): The user specified as a
definer ...") are missing a language tag and trigger MD040; update each
triple-backtick fence to include a language (use "text") so the blocks become
fenced as ```text, ensuring all error output blocks in this document (including
the authentication plugin error block) are annotated consistently.
- Around line 871-899: The checks that query mysql.proc will fail on MySQL 8.0;
update the SELECTs used to populate SOURCE_COUNT and TARGET_COUNT (the kubectl
exec mysql -e "...") to query information_schema.ROUTINES instead of mysql.proc
and use ROUTINE_SCHEMA = '${db}' and ROUTINE_TYPE = 'PROCEDURE' (for the Stored
Procedures block) or 'FUNCTION' (for the Stored Functions block); keep the
surrounding shell variables/logic (TOTAL_CHECKS, SOURCE_COUNT, TARGET_COUNT, db,
SOURCE_NAME/TARGET_NAME invocations) and only change the SQL string in both the
source and target kubectl exec calls.

Copy link
Contributor

@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: 1

🤖 Fix all issues with AI agents
In `@docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md`:
- Line 634: Replace the bolded authentication option titles with proper markdown
headings so they appear in the TOC: find the bold strings "**Option 1: Change
Users to mysql_native_password (Migration Compatibility)**" and the other two
bolded option lines (the entries at the same pattern) and convert them to
heading syntax (e.g., "### Option 1: Change Users to mysql_native_password
(Migration Compatibility)") ensuring consistent heading level for all three
occurrences so they are included in the document's table of contents.

Copy link
Contributor

@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: 3

🤖 Fix all issues with AI agents
In `@docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md`:
- Around line 1127-1138: Replace the bold subsection labels with proper Markdown
headings so they appear in the TOC: change "**Script fails with \"Cannot connect
to Kubernetes cluster\"**", "**Script fails with \"Source cluster not
found\"**", and "**Migration fails for specific database**" to heading syntax
(e.g., "#### Script fails with \"...\"") and ensure the following fenced code
blocks include language markers like ```bash so the commands render correctly;
update the three subsections in the document to use the heading tokens and
proper fenced code blocks accordingly.
- Around line 904-1111: Add the missing code-fence language tag "text" to the
expected-output blocks shown under the Pre-Migration Check, the "Expected
Output" section in "Script 2: Complete Migration" (the large migration run
sample) and the "Expected Output" section in "Script 3: Comprehensive
Verification" so each triple-backtick fence becomes ```text; locate these blocks
by the headings "MySQL 5.7 to 8.0 Pre-Migration Check", "MySQL 5.7 to 8.0
Migration" (Script 2) and "MySQL 5.7 to 8.0 Migration Verification" (Script 3)
and update their opening fences only.
- Around line 76-80: The table and prerequisites contain broken internal link
fragments; update the links in the table rows and prerequisites so they match
the actual heading IDs: replace `#schema-compatibility-analysis` with
`#step-2-schema-compatibility-analysis` (heading "Step 2: Schema Compatibility
Analysis") and replace `#character-set-and-collation-analysis` with
`#step-3-character-set-and-collation-analysis` (heading "Step 3: Character Set
and Collation Analysis"); for the `#migration-procedure` link either create a
matching heading (e.g., add "### Migration Procedure" so the fragment
`#migration-procedure` resolves) or change that link to point to an appropriate
existing section (e.g., the actual migration step heading) and update all
instances accordingly.

Copy link
Contributor

@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: 4

🤖 Fix all issues with AI agents
In `@docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md`:
- Line 609: The fenced code blocks showing raw error messages are missing
language identifiers; update each error-message fence in
How_to_Migrate_MySQL_57_to_80.md (the three/four error example blocks around the
provided diff locations) to include the `text` language tag (i.e., change ``` to
```text) so rendering/MD040 is satisfied; locate the specific fences containing
lines like "ERROR 3546 (HY000) at line XX: Cannot update GTID_PURGED..." and the
other two/three error examples and prepend `text` to their opening
triple-backtick markers.
- Line 1075: Replace the troubleshooting subsection titles that are currently
plain bold text (e.g., '**Script fails with "Cannot connect to Kubernetes
cluster"**', '**Script fails with "Source cluster not found"**', '**Migration
fails for specific database**') with proper Markdown heading syntax (for example
prepend '#### ' to each title) so they become real headings and appear in the
table of contents; ensure the surrounding code blocks remain fenced and intact
and apply the same change to the other occurrences noted (around the lines
corresponding to the other two titles).
- Line 852: Update the three markdown fenced output blocks that currently start
with ``` (the ones whose content begins with the header
"======================================== MySQL 5.7 to 8.0 Pre-Migration Check
========================================") to include the language tag "text" on
the opening fence (i.e. change ``` to ```text) for each occurrence so the
examples are consistently marked as plain-text output.
- Around line 76-80: Update the broken internal link fragments in the table:
replace the fragment "#schema-compatibility-analysis" with
"#step-1-schema-compatibility-analysis" (matches heading "### Step 1: Schema
Compatibility Analysis") and replace "#character-set-and-collation-analysis"
with "#step-2-character-set-and-collation-analysis" (matches heading "### Step
2: Character Set and Collation Analysis"); for "#migration-procedure" locate the
actual "Migration Procedure" heading in the document and use its real generated
fragment slug (replace the table link with that exact slug); apply these same
three corrections for the other occurrences noted in the comment.
🧹 Nitpick comments (1)
docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md (1)

119-127: Consider documenting secure password handling alternatives.

Throughout the guide and scripts, MySQL passwords are passed via the -p${MYSQL_PASSWORD} command-line flag. While functional in containerized environments, this approach has security implications:

  • Passwords visible in process lists (kubectl exec command history)
  • Shell history may retain plaintext passwords
  • Pod security policies may log command arguments

While the current approach is acceptable for internal scripts, consider adding a security note or documenting the MYSQL_PWD environment variable alternative for production use:

# More secure alternative using environment variable
kubectl exec ${TARGET_NAME}-0 -n ${TARGET_NAMESPACE} -c mysql -- \
  bash -c "MYSQL_PWD='${MYSQL_PASSWORD}' mysql -uroot -e 'SELECT 1;'"

This is a minor improvement given the controlled ACP environment, but worth mentioning in the security-conscious sections.

Also applies to: 1215-1217, 1546-1552

@SuJinpei
Copy link
Contributor Author

SuJinpei commented Mar 2, 2026

@coderabbitai review again

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

@SuJinpei: I'll review the PR changes again.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@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: 1

♻️ Duplicate comments (1)
docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md (1)

2393-2394: ⚠️ Potential issue | 🟡 Minor

Fix broken fragment links in production checklist.

These anchors don’t match current heading slugs and break in-page navigation.

🔗 Suggested fix
-- [ ] Completed [Schema Compatibility Analysis](`#schema-compatibility-analysis`) and fixed all issues
-- [ ] Completed [Character Set Migration](`#character-set-and-collation-analysis`) if using legacy charsets
+- [ ] Completed [Schema Compatibility Analysis](`#step-1-schema-compatibility-analysis`) and fixed all issues
+- [ ] Completed [Character Set Migration](`#step-2-character-set-and-collation-analysis`) if using legacy charsets
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md` around lines 2393 - 2394,
The two checklist links referencing "(`#schema-compatibility-analysis`)" and
"(`#character-set-and-collation-analysis`)" are broken because their slugs don’t
match the current headings; update the two checklist items to use the exact
generated heading slugs for the "Schema Compatibility Analysis" and "Character
Set Migration"/"Character set and collation" sections (match case-normalized,
hyphenated slugs used by the markdown renderer), i.e., open the document, locate
the headings for Schema Compatibility and Character Set/Collation and replace
the anchor targets in the checklist lines so they exactly match those headings’
slugs (lowercase, hyphens, no extra punctuation).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md`:
- Line 1549: The script currently uses "set -e" but masks pipeline failures by
appending "|| true" to commands; replace those occurrences by enabling pipefail
(add "set -o pipefail" alongside "set -e") and remove the "|| true" from the
import pipelines, then explicitly capture the pipeline exit status (check "$?"
or use "if ! <pipeline>; then ... fi") and log a clear error message and exit
non‑zero when the import fails; apply the same change to the other instances
mentioned (the other "|| true" usages) and keep the existing schema existence
checks as a follow-up verification rather than the sole failure detector.

---

Duplicate comments:
In `@docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md`:
- Around line 2393-2394: The two checklist links referencing
"(`#schema-compatibility-analysis`)" and "(`#character-set-and-collation-analysis`)"
are broken because their slugs don’t match the current headings; update the two
checklist items to use the exact generated heading slugs for the "Schema
Compatibility Analysis" and "Character Set Migration"/"Character set and
collation" sections (match case-normalized, hyphenated slugs used by the
markdown renderer), i.e., open the document, locate the headings for Schema
Compatibility and Character Set/Collation and replace the anchor targets in the
checklist lines so they exactly match those headings’ slugs (lowercase, hyphens,
no extra punctuation).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3dd2ef and bbf2539.

📒 Files selected for processing (1)
  • docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md

#
#=============================================================================

set -e # Exit on error
Copy link
Contributor

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:

# First, let's read the file and check the line counts and content around line 1549
wc -l docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md

Repository: alauda/knowledge

Length of output: 115


🏁 Script executed:

# Read the area around line 1549 to see the actual content
sed -n '1545,1555p' docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md

Repository: alauda/knowledge

Length of output: 444


🏁 Script executed:

# Search for the pipe/true patterns and set -e in the file
rg -n 'set -e|set -euo|set -o pipefail|\|\| true' docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md | head -30

Repository: alauda/knowledge

Length of output: 698


🏁 Script executed:

# Check the anchor references around lines 2393-2394
sed -n '2390,2400p' docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md

Repository: alauda/knowledge

Length of output: 754


🏁 Script executed:

# Let's also look at the broader context of the migration script to understand error handling
sed -n '1670,1720p' docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md

Repository: alauda/knowledge

Length of output: 2061


🏁 Script executed:

# Search for the anchor definitions in the document
rg -n '#{1,6}\s.*(schema.compatibility|character.set.*collation)' docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md -i

Repository: alauda/knowledge

Length of output: 266


🏁 Script executed:

# Also search for markdown anchor syntax if any
rg -n '<a.*id=|###|##' docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md | grep -i 'schema\|collation\|character'

Repository: alauda/knowledge

Length of output: 233


🏁 Script executed:

# Let's get a better view of the entire migration database section to understand the error handling flow
sed -n '1680,1710p' docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md

Repository: alauda/knowledge

Length of output: 1289


🏁 Script executed:

# Let me verify the actual anchor references at lines 2393-2394
sed -n '2390,2400p' docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md

Repository: alauda/knowledge

Length of output: 754


🏁 Script executed:

# Now let's check the full context of the checklist to see exact anchor links
sed -n '2380,2410p' docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md

Repository: alauda/knowledge

Length of output: 1796


🏁 Script executed:

# Verify the exact headers that exist and would auto-generate anchors
rg -n '^#{1,3}\s' docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md | grep -i 'schema compatibility\|character set.*collation'

Repository: alauda/knowledge

Length of output: 266


Improve error handling in migration pipeline: errors are masked and not properly reported.

Line 1689's || true suppresses pipeline errors, preventing error detection despite the subsequent schema existence check catching failed imports. While the database existence verification prevents completely silent failures, error conditions are hidden from operator visibility. The pattern should explicitly handle and log pipeline errors.

Consider adding explicit error handling to report pipeline failures:

-                mysql -uroot -p${TARGET_MYSQL_PASSWORD} --init-command="SET FOREIGN_KEY_CHECKS=0;" 2>&1 | grep -v "Using a password" || true
+                mysql -uroot -p${TARGET_MYSQL_PASSWORD} --init-command="SET FOREIGN_KEY_CHECKS=0;" 2>&1 | grep -v "Using a password"
+        if [ $? -ne 0 ]; then
+            print_error "Import pipeline encountered errors for ${db}"
+        fi

This also applies to similar patterns at lines 1740, 1769, and 1775.

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

In `@docs/en/solutions/How_to_Migrate_MySQL_57_to_80.md` at line 1549, The script
currently uses "set -e" but masks pipeline failures by appending "|| true" to
commands; replace those occurrences by enabling pipefail (add "set -o pipefail"
alongside "set -e") and remove the "|| true" from the import pipelines, then
explicitly capture the pipeline exit status (check "$?" or use "if ! <pipeline>;
then ... fi") and log a clear error message and exit non‑zero when the import
fails; apply the same change to the other instances mentioned (the other "||
true" usages) and keep the existing schema existence checks as a follow-up
verification rather than the sole failure detector.

Copy link

@sinbadonline sinbadonline left a comment

Choose a reason for hiding this comment

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

LGTM

@SuJinpei SuJinpei deployed to translate March 2, 2026 07:04 — with GitHub Actions Active
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.

2 participants