Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync-diff-inspector: add session configuration in toml #847

Merged
merged 11 commits into from
Feb 27, 2025

Conversation

joechenrh
Copy link
Contributor

@joechenrh joechenrh commented Feb 7, 2025

What problem does this PR solve?

Issue Number: ref #836, close #844

What is changed and how it works?

Add session variable configuration for each data source.

Check List

Tests

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

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation
  • Need to be included in the release note

@joechenrh
Copy link
Contributor Author

/release-note-none

@alastori
Copy link

alastori commented Feb 7, 2025

Will also close #844

@ti-chi-bot ti-chi-bot bot added size/L and removed size/M labels Feb 24, 2025
@joechenrh
Copy link
Contributor Author

/retest

@joechenrh
Copy link
Contributor Author

/retest

@joechenrh
Copy link
Contributor Author

/cc @kennytm

@ti-chi-bot ti-chi-bot bot requested a review from kennytm February 25, 2025 06:58
for param, value := range d.SessionConfig {
switch v := value.(type) {
case string:
cfg.Params[param] = "\"" + v + "\""
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cfg.Params[param] = "\"" + v + "\""
cfg.Params[param] = "'" + strings.ReplaceAll(v, "'", "''") + "'"

return nil
}
for param, value := range *sessionCfg {
res, err := db.Query(fmt.Sprintf("show session variables like '%s'", param))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
res, err := db.Query(fmt.Sprintf("show session variables like '%s'", param))
res, err := db.Query("show session variables like ?", param)

case string:
cfg.Params[param] = "\"" + v + "\""
default:
cfg.Params[param] = fmt.Sprintf("%v", v)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cfg.Params[param] = fmt.Sprintf("%v", v)
cfg.Params[param] = fmt.Sprint(v)

if err := res.Scan(&paramName, &actual); err != nil {
return err
}
expected := fmt.Sprintf("%v", value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expected := fmt.Sprintf("%v", value)
expected := fmt.Sprint(value)

Comment on lines 279 to 281
log.Error(fmt.Sprintf("failed to configure session for data source '%s'", cfg.Task.Target),
zap.String("error", err.Error()),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log.Error(fmt.Sprintf("failed to configure session for data source '%s'", cfg.Task.Target),
zap.String("error", err.Error()),
)
log.Error("failed to configure session", zap.String("data-source", cfg.Task.Target), zap.Error(err))

printf should be avoided when using structured logging

Comment on lines 300 to 302
log.Error(fmt.Sprintf("failed to configure session for data source '%s'", cfg.Task.Source[sourceIdx]),
zap.String("error", err.Error()),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log.Error(fmt.Sprintf("failed to configure session for data source '%s'", cfg.Task.Source[sourceIdx]),
zap.String("error", err.Error()),
)
log.Error("failed to configure session", zap.String("data-source", cfg.Task.Source[sourceIdx]), zap.Error(err))

@ti-chi-bot ti-chi-bot bot added size/M and removed size/L labels Feb 26, 2025
@ti-chi-bot ti-chi-bot bot added the lgtm label Feb 27, 2025
Copy link

ti-chi-bot bot commented Feb 27, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kennytm

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

The pull request process is described here

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

Copy link

ti-chi-bot bot commented Feb 27, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-02-27 09:46:43.045065689 +0000 UTC m=+521950.998223947: ☑️ agreed by kennytm.

@ti-chi-bot ti-chi-bot bot added the approved label Feb 27, 2025
@ti-chi-bot ti-chi-bot bot merged commit 89f3abd into pingcap:master Feb 27, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add max_execution_time parameter for sync diff inspector
3 participants