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

lightning: fix in-correctly check for session variable #29291

Merged
merged 10 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions br/pkg/lightning/lightning.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ type Lightning struct {
}

func initEnv(cfg *config.GlobalConfig) error {
if cfg.App.Config.File == "" {
return nil
}
return log.InitLogger(&cfg.App.Config, cfg.TiDB.LogLevel)
}

Expand Down
1 change: 1 addition & 0 deletions br/pkg/lightning/restore/table_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func createColumnPermutation(columns []string, ignoreColumns []string, tableInfo
func (tr *TableRestore) restoreEngines(pCtx context.Context, rc *Controller, cp *checkpoints.TableCheckpoint) error {
indexEngineCp := cp.Engines[indexEngineID]
if indexEngineCp == nil {
tr.logger.Error("fail to restoreEngines because indexengine is nil")
return errors.Errorf("table %v index engine checkpoint not found", tr.tableName)
}
// If there is an index engine only, it indicates no data needs to restore.
Expand Down
7 changes: 7 additions & 0 deletions br/pkg/lightning/restore/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,20 @@ func DBFromConfig(ctx context.Context, dsn config.DBStore) (*sql.DB, error) {
}
}

if dsn.Vars != nil {
glorv marked this conversation as resolved.
Show resolved Hide resolved
for k, v := range dsn.Vars {
vars[k] = v
}
}
for k, v := range vars {
q := fmt.Sprintf("SET SESSION %s = %s;", k, v)
log.L().Info("Set session", zap.String("query", q))
if _, err1 := db.ExecContext(ctx, q); err1 != nil {
log.L().Warn("set session variable failed, will skip this query", zap.String("query", q),
zap.Error(err1))
delete(vars, k)
}
log.L().Info("Set session End")
}
_ = db.Close()

Expand Down