Skip to content
Merged
4 changes: 2 additions & 2 deletions pkg/executor/plan_replayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func loadVariables(ctx sessionctx.Context, z *zip.Reader) error {
}
//nolint: errcheck,all_revive,revive
defer v.Close()
unLoadVars, err = config.LoadConfig(ctx, v)
unLoadVars, err = config.LoadConfigForPlanReplayerLoad(ctx, v)
if err != nil {
return errors.AddStack(err)
}
Expand Down Expand Up @@ -452,7 +452,7 @@ func loadStats(ctx sessionctx.Context, f *zip.File) error {
do := domain.GetDomain(ctx)
h := do.StatsHandle()
if h == nil {
return errors.New("plan replayer: hanlde is nil")
return errors.New("plan replayer: handle is nil")
}
return h.LoadStatsFromJSON(context.Background(), ctx.GetInfoSchema().(infoschema.InfoSchema), jsonTbl, 0)
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/statistics/handle/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ func UpdateSCtxVarsForStats(sctx sessionctx.Context) error {
return err
}
sctx.GetSessionVars().AnalyzePartitionMergeConcurrency = int(ver)
// sync innodb_lock_wait_timeout
val, err = sctx.GetSessionVars().GlobalVarsAccessor.GetGlobalSysVar(vardef.InnodbLockWaitTimeout)
if err != nil {
return err
}
lockWaitSec, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return err
}
sctx.GetSessionVars().LockWaitTimeout = lockWaitSec * 1000
return nil
}

Expand Down
12 changes: 10 additions & 2 deletions pkg/util/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ import (
"go.uber.org/zap"
)

// LoadConfig loads system variables from a toml reader. it is only for plan replayer and test.
func LoadConfig(ctx sessionctx.Context, v io.ReadCloser) (unLoadVars []string, err error) {
var ignoredSystemVariablesForPlanReplayerLoad = map[string]struct{}{
vardef.InnodbLockWaitTimeout: {}, // It is unnecessary to load this variable for plan replayer.
}

// LoadConfigForPlanReplayerLoad loads system variables from a toml reader. it is only for plan replayer and test.
func LoadConfigForPlanReplayerLoad(ctx sessionctx.Context, v io.ReadCloser) (unLoadVars []string, err error) {
varMap := make(map[string]string)

_, err = toml.NewDecoder(v).Decode(&varMap)
Expand All @@ -38,6 +42,10 @@ func LoadConfig(ctx sessionctx.Context, v io.ReadCloser) (unLoadVars []string, e
unLoadVars = make([]string, 0)
vars := ctx.GetSessionVars()
for name, value := range varMap {
if _, ok := ignoredSystemVariablesForPlanReplayerLoad[name]; ok {
logutil.BgLogger().Warn(fmt.Sprintf("ignore set variable %s:%s", name, value), zap.Error(err))
continue
}
sysVar := variable.GetSysVar(name)
if sysVar == nil {
unLoadVars = append(unLoadVars, name)
Expand Down