Skip to content

dumpling: New terminology for MySQL (#57188)#66854

Closed
ti-chi-bot wants to merge 10 commits intopingcap:release-8.5from
ti-chi-bot:cherry-pick-57188-to-release-8.5
Closed

dumpling: New terminology for MySQL (#57188)#66854
ti-chi-bot wants to merge 10 commits intopingcap:release-8.5from
ti-chi-bot:cherry-pick-57188-to-release-8.5

Conversation

@ti-chi-bot
Copy link
Member

@ti-chi-bot ti-chi-bot commented Mar 10, 2026

This is an automated cherry-pick of #57188

What problem does this PR solve?

Issue Number: close #53082

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Dumpling now supports dumpling databases from MySQL 8.4 and newer

Summary by CodeRabbit

  • Bug Fixes

    • Improved compatibility with MySQL 8.4+ by implementing version-aware command selection for binary log and replication status operations, ensuring proper functionality with newer MySQL versions.
  • Tests

    • Expanded integration test matrix to include MySQL version 8.4.3, enhancing version coverage.

@ti-chi-bot ti-chi-bot added component/dumpling This is related to Dumpling of TiDB. ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Mar 10, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 10, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign gmhdbjd for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

📝 Walkthrough

Walkthrough

This pull request adds support for MySQL 8.4.0 by introducing version-aware logic to use new terminology (SHOW BINARY LOG STATUS, SHOW REPLICA STATUS) instead of deprecated SHOW MASTER STATUS and SHOW SLAVE STATUS commands. Function signatures are updated to pass ServerInfo instead of ServerType for version-aware command selection.

Changes

Cohort / File(s) Summary
Version Configuration
dumpling/export/config.go
Introduces minNewTerminologyMySQL version constant (8.4.0) marking the first MySQL version with new terminology support.
Function Signature Updates
dumpling/export/dump.go, dumpling/export/metadata.go, dumpling/export/sql.go
Updates recordGlobalMetaData and ShowMasterStatus function signatures to accept ServerInfo instead of ServerType, enabling version-aware command selection for MySQL 8.4.0+.
Version-Aware Command Logic
dumpling/export/metadata.go
Implements conditional logic to select between SHOW MASTER/BINARY LOG STATUS and SHOW SLAVE/REPLICA STATUS based on server version and type, with special handling for MariaDB and TiDB.
Test Updates
dumpling/export/metadata_test.go
Updates all test calls to pass ServerInfo struct wrappers instead of raw ServerType enum values.
Integration and CI
.github/workflows/integration-test-dumpling.yml, dumpling/tests/consistency/run.sh
Adds MySQL 8.4.3 to test matrix and implements version-aware metadata retrieval logic in shell scripts to support the new MySQL terminology.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through MySQL's refactored land,
Where MASTER becomes BINARY LOG, quite grand!
Version 8.4 now speaks with tongue anew,
REPLICA replaces SLAVE in every view—
Dumpling exports with terminology true! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title 'dumpling: New terminology for MySQL' directly relates to the main change: updating Dumpling to support MySQL 8.4 by replacing deprecated SQL commands.
Description check ✅ Passed Description includes issue number (#53082), indicates manual tests performed, notes MySQL compatibility changes, and provides release notes.
Linked Issues check ✅ Passed Changes fulfill issue #53082 requirements: replaced SHOW MASTER/SLAVE STATUS commands with version-aware alternatives (SHOW BINARY LOG/REPLICA STATUS for MySQL 8.4+) across metadata.go, sql.go, and added MySQL 8.4.3 to CI.
Out of Scope Changes check ✅ Passed All changes directly support MySQL 8.4 compatibility: new terminology variables, version checks, updated SQL commands, metadata handling, and CI updates are all aligned with issue #53082 objectives.

✏️ 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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


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

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@dumpling/export/metadata_test.go`:
- Line 43: Add a real MySQL 8.4 regression test by calling recordGlobalMetaData
with a ServerInfo that includes ServerVersion: semver.New("8.4.0") (e.g.,
version.ServerInfo{ServerType: version.ServerTypeMySQL, ServerVersion:
semver.New("8.4.0")}) so the MySQL 8.4 branches run; in metadata_test.go add an
assertion that the executed query is the new "SHOW BINARY LOG STATUS" (and the
corresponding replica query "SHOW REPLICA STATUS" if applicable) and assert the
emitted metadata text matches the expected output for 8.4; apply the same change
pattern to the other test call sites you listed (lines 75-76, 111, 143, 174,
200, 242, 269-282, 306) so at least one test exercises the new MySQL 8.4
behavior and fails before the fix and passes after.

In `@dumpling/export/metadata.go`:
- Around line 68-77: The header logic in recordGlobalMetaData's
writeMasterStatusHeader currently bases the label solely on ServerVersion,
causing MariaDB (or other non-MySQL) servers with newer parsed versions to emit
"SHOW BINARY LOG STATUS:" even though dumpling/export/sql.go still runs "SHOW
MASTER STATUS"; update writeMasterStatusHeader to require serverInfo.ServerType
== version.ServerTypeMySQL in addition to the existing ServerVersion check (and
minNewTerminologyMySQL comparison) so the header only flips for MySQL
servers—modify the conditional in writeMasterStatusHeader within
recordGlobalMetaData to include that server type guard.
- Around line 176-184: The metadata writer currently hardcodes the header "SHOW
SLAVE STATUS:" for follower entries even though the earlier logic sets the
actual SQL string in the local variable query (which may be "SHOW REPLICA
STATUS" for MySQL 8.4+ or "SHOW ALL SLAVES STATUS" for MariaDB); update the
formatter that emits follower entries to use the query variable as the header
instead of the fixed string so the metadata reflects the actual command run
(locate the code that prints each follower entry and replace the hardcoded
header with the query variable).

In `@dumpling/tests/consistency/run.sh`:
- Around line 35-44: The script uses bash-only [[ ... =~ ... ]] tests on
variable versioninfo when deciding which SHOW command to run (setting metadata
via run_sql), which breaks under /bin/sh; fix by either changing the shebang to
#!/bin/bash or rewriting the checks to POSIX-compatible tests: replace the [[
$versioninfo =~ (Ti|Maria)DB ]] check with a case or a grep-based test (e.g.
case "$versioninfo" in *TiDB*|*MariaDB*) and replace the VERSION() regex test
with grep -E 'VERSION\(\): (8\.4|9)' (or an equivalent case pattern) so the
logic that calls run_sql "show master status;" or run_sql "show binary log
status;" remains identical but works under a POSIX shell.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0eb89651-7837-4c57-ad22-76d60fe4f1c7

📥 Commits

Reviewing files that changed from the base of the PR and between 802f3eb and 3c1129e.

📒 Files selected for processing (7)
  • .github/workflows/integration-test-dumpling.yml
  • dumpling/export/config.go
  • dumpling/export/dump.go
  • dumpling/export/metadata.go
  • dumpling/export/metadata_test.go
  • dumpling/export/sql.go
  • dumpling/tests/consistency/run.sh


m := newGlobalMetadata(tcontext.Background(), createStorage(t), "")
require.NoError(t, m.recordGlobalMetaData(conn, version.ServerTypeMySQL, false))
require.NoError(t, m.recordGlobalMetaData(conn, version.ServerInfo{ServerType: version.ServerTypeMySQL}, false))
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add a real MySQL 8.4 regression test.

All of these updated call sites still pass version.ServerInfo{ServerType: ...} with ServerVersion == nil, so recordGlobalMetaData() only exercises the legacy SHOW MASTER STATUS / SHOW SLAVE STATUS branches. That means this PR can still pass without covering the new MySQL 8.4 behavior (SHOW BINARY LOG STATUS and SHOW REPLICA STATUS). Please add at least one case with ServerVersion: semver.New("8.4.0") and assert both the executed query and the emitted metadata text.

As per coding guidelines MUST add a regression test and verify it fails before fix and passes after fix for bug fixes.

Also applies to: 75-76, 111-111, 143-143, 174-174, 200-200, 242-242, 269-282, 306-306

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

In `@dumpling/export/metadata_test.go` at line 43, Add a real MySQL 8.4 regression
test by calling recordGlobalMetaData with a ServerInfo that includes
ServerVersion: semver.New("8.4.0") (e.g., version.ServerInfo{ServerType:
version.ServerTypeMySQL, ServerVersion: semver.New("8.4.0")}) so the MySQL 8.4
branches run; in metadata_test.go add an assertion that the executed query is
the new "SHOW BINARY LOG STATUS" (and the corresponding replica query "SHOW
REPLICA STATUS" if applicable) and assert the emitted metadata text matches the
expected output for 8.4; apply the same change pattern to the other test call
sites you listed (lines 75-76, 111, 143, 174, 200, 242, 269-282, 306) so at
least one test exercises the new MySQL 8.4 behavior and fails before the fix and
passes after.

Comment on lines +68 to +77
func recordGlobalMetaData(tctx *tcontext.Context, db *sql.Conn, buffer *bytes.Buffer, serverInfo version.ServerInfo, afterConn bool, snapshot string) error { // revive:disable-line:flag-parameter
serverType := serverInfo.ServerType
writeMasterStatusHeader := func() {
buffer.WriteString("SHOW MASTER STATUS:")
if serverInfo.ServerVersion == nil {
buffer.WriteString("SHOW MASTER STATUS:")
} else if serverInfo.ServerVersion.LessThan(*minNewTerminologyMySQL) {
buffer.WriteString("SHOW MASTER STATUS:")
} else {
buffer.WriteString("SHOW BINARY LOG STATUS:")
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Only flip the header for MySQL.

writeMasterStatusHeader() now keys off ServerVersion alone, so MariaDB 11.x will emit SHOW BINARY LOG STATUS: even though dumpling/export/sql.go still executes SHOW MASTER STATUS for MariaDB. The same drift can happen for any non-MySQL server whose parsed version crosses 8.4.0. Gate this on serverInfo.ServerType == version.ServerTypeMySQL too.

Proposed fix
 	writeMasterStatusHeader := func() {
-		if serverInfo.ServerVersion == nil {
-			buffer.WriteString("SHOW MASTER STATUS:")
-		} else if serverInfo.ServerVersion.LessThan(*minNewTerminologyMySQL) {
-			buffer.WriteString("SHOW MASTER STATUS:")
-		} else {
+		if serverInfo.ServerType == version.ServerTypeMySQL &&
+			serverInfo.ServerVersion != nil &&
+			!serverInfo.ServerVersion.LessThan(*minNewTerminologyMySQL) {
 			buffer.WriteString("SHOW BINARY LOG STATUS:")
+		} else {
+			buffer.WriteString("SHOW MASTER STATUS:")
 		}
 		if afterConn {
 			buffer.WriteString(" /* AFTER CONNECTION POOL ESTABLISHED */")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dumpling/export/metadata.go` around lines 68 - 77, The header logic in
recordGlobalMetaData's writeMasterStatusHeader currently bases the label solely
on ServerVersion, causing MariaDB (or other non-MySQL) servers with newer parsed
versions to emit "SHOW BINARY LOG STATUS:" even though dumpling/export/sql.go
still runs "SHOW MASTER STATUS"; update writeMasterStatusHeader to require
serverInfo.ServerType == version.ServerTypeMySQL in addition to the existing
ServerVersion check (and minNewTerminologyMySQL comparison) so the header only
flips for MySQL servers—modify the conditional in writeMasterStatusHeader within
recordGlobalMetaData to include that server type guard.

Comment on lines 176 to +184
if isms {
query = "SHOW ALL SLAVES STATUS"
query = "SHOW ALL SLAVES STATUS" // MariaDB
} else if serverInfo.ServerVersion == nil {
query = "SHOW SLAVE STATUS" // Unknown version
} else if serverInfo.ServerType == version.ServerTypeMySQL &&
!serverInfo.ServerVersion.LessThan(*minNewTerminologyMySQL) {
query = "SHOW REPLICA STATUS" // MySQL 8.4.0 and newer
} else {
query = "SHOW SLAVE STATUS"
query = "SHOW SLAVE STATUS" // MySQL
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Use the selected follower-status command in the metadata output.

This branch now chooses SHOW REPLICA STATUS for MySQL 8.4+, but the formatter below still hardcodes SHOW SLAVE STATUS: before every follower entry. The metadata file will therefore advertise the wrong statement even when the query succeeded. Please derive that header from query instead of a fixed string.

Proposed fix
-		if len(host) > 0 {
-			buffer.WriteString("SHOW SLAVE STATUS:\n")
+		if len(host) > 0 {
+			buffer.WriteString(query + ":\n")
 			if isms {
 				buffer.WriteString("\tConnection name: " + connName + "\n")
 			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dumpling/export/metadata.go` around lines 176 - 184, The metadata writer
currently hardcodes the header "SHOW SLAVE STATUS:" for follower entries even
though the earlier logic sets the actual SQL string in the local variable query
(which may be "SHOW REPLICA STATUS" for MySQL 8.4+ or "SHOW ALL SLAVES STATUS"
for MariaDB); update the formatter that emits follower entries to use the query
variable as the header instead of the fixed string so the metadata reflects the
actual command run (locate the code that prints each follower entry and replace
the hardcoded header with the query variable).

Comment on lines +35 to +44
if [[ $versioninfo =~ (Ti|Maria)DB ]]; then
metadata=`run_sql "show master status;"`
else
if [[ $versioninfo =~ "VERSION(): "(8.4|9) ]]; then
# MySQL 8.4.0 and newer no longer support SHOW MASTER STATUS
# and only support SHOW BINARY LOG STATUS
metadata=`run_sql "show binary log status;"`
else
metadata=`run_sql "show master status;"`
fi
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
sed -n '1p;35,44p' dumpling/tests/consistency/run.sh
python - <<'PY'
from pathlib import Path

lines = Path("dumpling/tests/consistency/run.sh").read_text().splitlines()
print("shebang:", lines[0])
for i, line in enumerate(lines, 1):
    if "[[" in line or "=~" in line:
        print(f"{i}: {line}")
PY

Repository: pingcap/tidb

Length of output: 540


Fix POSIX compatibility or change shebang to bash.

The script declares #!/bin/sh but uses bash-only [[ ... =~ ... ]] syntax on lines 35 and 38. This causes a parsing error on POSIX-compliant shells like dash or ash, preventing the consistency test from running at all. Either rewrite the version checks using POSIX case/grep, or change the shebang to #!/bin/bash if bash is guaranteed in the test environment.

🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 35-35: In POSIX sh, [[ ]] is undefined.

(SC3010)


[warning] 35-35: In POSIX sh, =~ regex matching is undefined.

(SC3015)


[warning] 38-38: In POSIX sh, [[ ]] is undefined.

(SC3010)


[warning] 38-38: In POSIX sh, =~ regex matching is undefined.

(SC3015)

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

In `@dumpling/tests/consistency/run.sh` around lines 35 - 44, The script uses
bash-only [[ ... =~ ... ]] tests on variable versioninfo when deciding which
SHOW command to run (setting metadata via run_sql), which breaks under /bin/sh;
fix by either changing the shebang to #!/bin/bash or rewriting the checks to
POSIX-compatible tests: replace the [[ $versioninfo =~ (Ti|Maria)DB ]] check
with a case or a grep-based test (e.g. case "$versioninfo" in *TiDB*|*MariaDB*)
and replace the VERSION() regex test with grep -E 'VERSION\(\): (8\.4|9)' (or an
equivalent case pattern) so the logic that calls run_sql "show master status;"
or run_sql "show binary log status;" remains identical but works under a POSIX
shell.

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 38.88889% with 22 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-8.5@802f3eb). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.5     #66854   +/-   ##
================================================
  Coverage               ?   55.0111%           
================================================
  Files                  ?       1819           
  Lines                  ?     652532           
  Branches               ?          0           
================================================
  Hits                   ?     358965           
  Misses                 ?     266928           
  Partials               ?      26639           
Flag Coverage Δ
integration 38.2086% <ø> (?)
unit 65.0365% <38.8888%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.7474% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 55.3997% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 10, 2026

@ti-chi-bot: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/unit-test 3c1129e link true /test unit-test

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@dveeden
Copy link
Contributor

dveeden commented Mar 10, 2026

We already have #65131 for this

@dveeden dveeden closed this Mar 10, 2026
@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-approved Cherry pick PR approved by release team. component/dumpling This is related to Dumpling of TiDB. ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants