Skip to content

DM: Extend MySQL and MariaDB support for newer versions#12628

Open
dveeden wants to merge 9 commits into
pingcap:masterfrom
dveeden:tagged_gtid
Open

DM: Extend MySQL and MariaDB support for newer versions#12628
dveeden wants to merge 9 commits into
pingcap:masterfrom
dveeden:tagged_gtid

Conversation

@dveeden
Copy link
Copy Markdown
Contributor

@dveeden dveeden commented May 7, 2026

Updated go-mysql

What problem does this PR solve?

Issue Number: closes #12629

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

Support for newer versions of MySQL and MariaDB was extended

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-triage-completed release-note Denotes a PR that will be considered when it comes time to generate release notes. area/dm Issues or PRs related to DM. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 7, 2026
@dveeden
Copy link
Copy Markdown
Contributor Author

dveeden commented May 7, 2026

/cc @OliverS929 @D3Hunter

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 updates the project to Go 1.25.9 and performs a significant upgrade of various dependencies, most notably go-mysql and tidb. The core changes involve refactoring GTID handling to align with the updated go-mysql library, including the transition from UUIDSet to MysqlGTIDSet and structural changes to MariaDB GTID sets. Feedback from the review highlights a potential side-effect in GTID incrementing that should be addressed by working on a copy of the data. Additionally, there are recommendations for improving code maintainability through the use of helper functions for repeated logic, removing redundant assignments, and simplifying loops where variables are unused.

Comment on lines 174 to 180
mariaGTID := singleGTID.(*gmysql.MariadbGTID)
mariaGTID.SequenceNumber++
gtidSet := new(gmysql.MariadbGTIDSet)
gtidSet.Sets = map[uint32]map[uint32]*gmysql.MariadbGTID{
mariaGTID.DomainID: {
mariaGTID.ServerID: mariaGTID,
},
gtidSet.Sets = map[uint32]*gmysql.MariadbGTID{
mariaGTID.DomainID: mariaGTID,
}
clone = gtidSet
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

In the MariaDB flavor case, mariaGTID is a pointer to an element within the original gSet. Modifying mariaGTID.SequenceNumber directly causes a side effect on the input gSet. To ensure GTIDIncrease is pure and doesn't modify its input, you should work on a copy of the GTID struct.

Suggested change
mariaGTID := singleGTID.(*gmysql.MariadbGTID)
mariaGTID.SequenceNumber++
gtidSet := new(gmysql.MariadbGTIDSet)
gtidSet.Sets = map[uint32]map[uint32]*gmysql.MariadbGTID{
mariaGTID.DomainID: {
mariaGTID.ServerID: mariaGTID,
},
gtidSet.Sets = map[uint32]*gmysql.MariadbGTID{
mariaGTID.DomainID: mariaGTID,
}
clone = gtidSet
mariaGTID := *singleGTID.(*gmysql.MariadbGTID)
mariaGTID.SequenceNumber++
gtidSet := new(gmysql.MariadbGTIDSet)
gtidSet.Sets = map[uint32]*gmysql.MariadbGTID{
mariaGTID.DomainID: &mariaGTID,
}
clone = gtidSet

Comment on lines +125 to +130
for u, tags := range *mSet {
sid = u
for _, intervals := range tags {
interval = intervals[0]
}
}
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

The logic for extracting the single SID and Interval from a MysqlGTIDSet is repeated here and in newGenerator (in generator.go). Since DM requires these sets to have exactly one entry (as enforced by verifySingleGTID), consider moving this extraction logic into a helper function to improve code reuse and maintainability.

for tag, intervals := range tags {
intervals[0].Start++
intervals[0].Stop++
(*mSet)[u][tag] = intervals
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 assignment is redundant because intervals is a slice, which is a reference type in Go. Modifying its elements on lines 167-168 already updates the data within the map. Removing this line would clarify that the modification is happening in-place on the cloned set.

Comment on lines +202 to +206
var sid uuid.UUID
var tags map[gmysql.Tag]gmysql.IntervalSlice
for sid, tags = range *mysqlGTIDs {
}
var uuidSet *gmysql.UUIDSet
for _, uuidSet = range mysqlGTIDs.Sets {
_ = sid
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

The variable sid is declared and assigned but not used, necessitating a blank assignment _ = sid to satisfy the compiler. This can be simplified by using a blank identifier directly in the range loop.

		var tags map[gmysql.Tag]gmysql.IntervalSlice
		for _, tags = range *mysqlGTIDs {
		}

@dveeden dveeden force-pushed the tagged_gtid branch 2 times, most recently from e147389 to 59316e0 Compare May 7, 2026 12:10
@dveeden
Copy link
Copy Markdown
Contributor Author

dveeden commented May 8, 2026

/retest

@wuhuizuo wuhuizuo changed the title DM: Extend MySQL and MariaDB support for newer versions DM: Extend MySQL and MariaDB support for newer versions May 8, 2026
@wuhuizuo wuhuizuo changed the title DM: Extend MySQL and MariaDB support for newer versions DM: Extend MySQL and MariaDB support for newer versions May 8, 2026
ti-chi-bot Bot pushed a commit to PingCAP-QE/ci that referenced this pull request May 9, 2026
#4578)

### What

Update TiFlow latest CI images to the newer Go 1.25 image tag:

- `ghcr.io/pingcap-qe/ci/jenkins:v2026.4.12-10-gc29110c-go1.25` for
jenkins job
- `ghcr.io/pingcap-qe/ci/base:v2026.4.12-10-gc29110c-go1.25` for the
Prow unit test job

### Why

TiFlow PR pingcap/tiflow#12628 updates `go.mod` to `go 1.25.9`.
Some CI jobs were still running with older Go 1.25 images, causing
errors like:
```text
compile: version "go1.25.9" does not match go tool version "go1.25.8" 
``` 
### Test result
I have run replay tests for all failed tasks. The Go version mismatch
issue is now fully resolved. The remaining failures are either
integration test failures inherent to the TiFlow PR itself, or runtime
issues on individual Jenkins/K8s agents. These are not directly related
to the current upgrade of the Go image.

---------

Signed-off-by: lyb <yebin.li@pingcap.com>
@wuhuizuo
Copy link
Copy Markdown
Contributor

wuhuizuo commented May 9, 2026

/test pull-verify

@dveeden
Copy link
Copy Markdown
Contributor Author

dveeden commented May 11, 2026

/retest

@ti-chi-bot ti-chi-bot Bot added the area/engine Issues or PRs related to Dataflow Engine. label May 11, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented May 11, 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 lance6716 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

@dveeden
Copy link
Copy Markdown
Contributor Author

dveeden commented May 11, 2026

/retest

1 similar comment
@dveeden
Copy link
Copy Markdown
Contributor Author

dveeden commented May 11, 2026

/retest

go-mysql v1.15.0 (PR pingcap#1080) decodes upstream heartbeat events as a
dedicated *replication.HeartbeatEvent type instead of GenericEvent.
DM's switches on *replication.GenericEvent no longer match real
heartbeats, so the validator never persists checkpoints, the syncer
never flushes on idle, and the relay no longer marks heartbeats as
ignored. This caused validator_basic to hang with non-zero pending
rows. Accept both types since DM still injects its own heartbeats
locally as GenericEvent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dveeden
Copy link
Copy Markdown
Contributor Author

dveeden commented May 11, 2026

/retest

The test asserted finished_bytes=59674 verbatim, but the tidb-pkg
upgrade in this branch ships a slightly different lightning that
reports 59754 bytes for the same dumped data. Replace the literal
byte count with a backreference assertion that finished_bytes equals
total_bytes (and is non-empty), so the test no longer breaks on
benign size shifts from lightning.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dveeden
Copy link
Copy Markdown
Contributor Author

dveeden commented May 11, 2026

/retest pull-verify

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented May 11, 2026

@dveeden: The /retest command does not accept any targets.
The following commands are available to trigger required jobs:

/test pull-build
/test pull-cdc-integration-kafka-test
/test pull-cdc-integration-mysql-test
/test pull-cdc-integration-pulsar-test
/test pull-cdc-integration-storage-test
/test pull-check
/test pull-dm-compatibility-test
/test pull-dm-integration-test
/test pull-error-log-review
/test pull-syncdiff-integration-test
/test pull-unit-test-cdc
/test pull-verify
/test wip-pull-unit-test-dm
/test wip-pull-unit-test-engine

The following commands are available to trigger optional jobs:

/test pull-dm-integration-test-next-gen

Use /test all to run the following jobs that were automatically triggered:

pingcap/tiflow/ghpr_verify
pingcap/tiflow/pull_cdc_integration_kafka_test
pingcap/tiflow/pull_cdc_integration_pulsar_test
pingcap/tiflow/pull_cdc_integration_storage_test
pingcap/tiflow/pull_cdc_integration_test
pingcap/tiflow/pull_dm_compatibility_test
pingcap/tiflow/pull_dm_integration_test
pingcap/tiflow/pull_dm_integration_test_next_gen
pingcap/tiflow/pull_syncdiff_integration_test
pull-build
pull-check
pull-error-log-review
pull-unit-test-cdc
Details

In response to this:

/retest pull-verify

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.

@dveeden
Copy link
Copy Markdown
Contributor Author

dveeden commented May 11, 2026

/test pull-verify

@dveeden
Copy link
Copy Markdown
Contributor Author

dveeden commented May 11, 2026

/retest

1 similar comment
@dveeden
Copy link
Copy Markdown
Contributor Author

dveeden commented May 12, 2026

/retest

go-sql-driver/mysql v1.8 (bumped from v1.7.1 in this branch) returns
typed Go values (int64, float64, ...) when Scan'd into *interface{},
where v1.7 always returned []byte. ColumnsHolder.Values was scanned
through *interface{} and the canal-json / open-protocol handle-key-only
decoders type-assert .([]uint8) on every value, which now panics on any
non-string column (caught by the canal_json_handle_key_only integration
test).

Scan each column into *[]byte via a private rawValues slot instead, so
ints/floats/bools round-trip through database/sql's convertAssign and
land as their textual representation - matching the pre-v1.8 contract
that downstream decoders rely on. Use *[]byte rather than *sql.RawBytes
because rows.Close (deferred) invalidates RawBytes before the caller
reads the holder; *[]byte gets a fresh Go-owned slice.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented May 12, 2026

@dveeden: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-dm-integration-test-next-gen bbdf2ed link false /test pull-dm-integration-test-next-gen
pull-dm-integration-test bbdf2ed link true /test pull-dm-integration-test
pull-unit-test-cdc bbdf2ed link true /test pull-unit-test-cdc
pull-cdc-integration-kafka-test bbdf2ed link true /test pull-cdc-integration-kafka-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dm Issues or PRs related to DM. area/engine Issues or PRs related to Dataflow Engine. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tagged GTIDs

2 participants