-
Notifications
You must be signed in to change notification settings - Fork 198
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
Conversation
/release-note-none |
Will also close #844 |
/retest |
/retest |
/cc @kennytm |
sync_diff_inspector/config/config.go
Outdated
for param, value := range d.SessionConfig { | ||
switch v := value.(type) { | ||
case string: | ||
cfg.Params[param] = "\"" + v + "\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
res, err := db.Query(fmt.Sprintf("show session variables like '%s'", param)) | |
res, err := db.Query("show session variables like ?", param) |
sync_diff_inspector/config/config.go
Outdated
case string: | ||
cfg.Params[param] = "\"" + v + "\"" | ||
default: | ||
cfg.Params[param] = fmt.Sprintf("%v", v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cfg.Params[param] = fmt.Sprintf("%v", v) | |
cfg.Params[param] = fmt.Sprint(v) |
if err := res.Scan(¶mName, &actual); err != nil { | ||
return err | ||
} | ||
expected := fmt.Sprintf("%v", value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected := fmt.Sprintf("%v", value) | |
expected := fmt.Sprint(value) |
sync_diff_inspector/source/source.go
Outdated
log.Error(fmt.Sprintf("failed to configure session for data source '%s'", cfg.Task.Target), | ||
zap.String("error", err.Error()), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
sync_diff_inspector/source/source.go
Outdated
log.Error(fmt.Sprintf("failed to configure session for data source '%s'", cfg.Task.Source[sourceIdx]), | ||
zap.String("error", err.Error()), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)) |
[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 |
[LGTM Timeline notifier]Timeline:
|
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
Code changes
Side effects
Related changes