Skip to content

Modernize dm/pkg#12718

Open
dveeden wants to merge 4 commits into
pingcap:masterfrom
dveeden:modern_dm_pkg
Open

Modernize dm/pkg#12718
dveeden wants to merge 4 commits into
pingcap:masterfrom
dveeden:modern_dm_pkg

Conversation

@dveeden

@dveeden dveeden commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #12691

What is changed and how it works?

Check List

Tests

  • Manual test (add detailed scripts or steps below)

Questions

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

Release note

None

@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. area/dm Issues or PRs related to DM. labels Jun 16, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

[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 d3hunter 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

@ti-chi-bot ti-chi-bot Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 16, 2026

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

Copy link
Copy Markdown

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 modernizes the codebase by replacing interface{} with any, adopting for range loops for integer iterations, and leveraging standard library packages like slices and maps. However, several critical compilation errors are introduced where wg.Go is called on standard sync.WaitGroup instances, which do not support this method. Additionally, the performance of strings.Builder in basedb.go can be improved by using fmt.Fprintf directly instead of writing formatted strings, which avoids unnecessary allocations.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread dm/pkg/shardddl/pessimism/info_test.go
Comment thread dm/pkg/election/election_test.go
Comment thread dm/pkg/election/election.go
Comment thread dm/pkg/binlog/reader/file.go
Comment thread dm/pkg/checker/real_checker.go
Comment thread dm/pkg/conn/basedb.go Outdated
Comment thread dm/pkg/conn/basedb.go
Comment on lines 154 to 159
if rawCfg.ReadTimeout != "" {
dsn += fmt.Sprintf("&readTimeout=%s", rawCfg.ReadTimeout)
dsn.WriteString(fmt.Sprintf("&readTimeout=%s", rawCfg.ReadTimeout))
}
if rawCfg.WriteTimeout != "" {
dsn += fmt.Sprintf("&writeTimeout=%s", rawCfg.WriteTimeout)
dsn.WriteString(fmt.Sprintf("&writeTimeout=%s", rawCfg.WriteTimeout))
}

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

Using dsn.WriteString(fmt.Sprintf(...)) allocates intermediate strings. Use fmt.Fprintf directly with the strings.Builder to avoid unnecessary allocations and improve efficiency.

Suggested change
if rawCfg.ReadTimeout != "" {
dsn += fmt.Sprintf("&readTimeout=%s", rawCfg.ReadTimeout)
dsn.WriteString(fmt.Sprintf("&readTimeout=%s", rawCfg.ReadTimeout))
}
if rawCfg.WriteTimeout != "" {
dsn += fmt.Sprintf("&writeTimeout=%s", rawCfg.WriteTimeout)
dsn.WriteString(fmt.Sprintf("&writeTimeout=%s", rawCfg.WriteTimeout))
}
if rawCfg.ReadTimeout != "" {
fmt.Fprintf(&dsn, "&readTimeout=%s", rawCfg.ReadTimeout)
}
if rawCfg.WriteTimeout != "" {
fmt.Fprintf(&dsn, "&writeTimeout=%s", rawCfg.WriteTimeout)
}

Comment thread dm/pkg/conn/basedb.go Outdated
dveeden and others added 2 commits June 16, 2026 09:19
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@dveeden

dveeden commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

/cc @kennytm @GMHDBJD

@ti-chi-bot ti-chi-bot Bot requested review from GMHDBJD and kennytm June 16, 2026 07:37
@dveeden

dveeden commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

/retest

Resolve conflict in dm/pkg/storage/utils_test.go: upstream PR pingcap#12716
(loader(dm): update import-into external ID handling) removed the
StripS3ExternalID helper from dm/pkg/storage/utils.go in favor of the
lightning TikvImporter.StripS3ExternalIDForImportSQL config flag. Drop
the now-orphaned TestStripS3ExternalID test accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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. release-note-none Denotes a PR that doesn't merit a release note. 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.

1 participant