lightning: let session vars in config also impact kv encoder (#28877)
This commit is contained in:
@ -770,7 +770,12 @@ func (rc *Controller) restoreSchema(ctx context.Context) error {
|
||||
|
||||
go rc.listenCheckpointUpdates()
|
||||
|
||||
rc.sysVars = ObtainImportantVariables(ctx, rc.tidbGlue.GetSQLExecutor(), !rc.isTiDBBackend())
|
||||
sysVars := ObtainImportantVariables(ctx, rc.tidbGlue.GetSQLExecutor(), !rc.isTiDBBackend())
|
||||
// override by manually set vars
|
||||
for k, v := range rc.cfg.TiDB.Vars {
|
||||
sysVars[k] = v
|
||||
}
|
||||
rc.sysVars = sysVars
|
||||
|
||||
// Estimate the number of chunks for progress reporting
|
||||
err = rc.estimateChunkCountIntoMetrics(ctx)
|
||||
|
||||
@ -1553,8 +1553,23 @@ func (s *restoreSchemaSuite) TearDownTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *restoreSchemaSuite) TestRestoreSchemaSuccessful(c *C) {
|
||||
// before restore, if sysVars is initialized by other test, the time_zone should be default value
|
||||
if len(s.rc.sysVars) > 0 {
|
||||
tz, ok := s.rc.sysVars["time_zone"]
|
||||
c.Assert(ok, IsTrue)
|
||||
c.Assert(tz, Equals, "SYSTEM")
|
||||
}
|
||||
|
||||
s.rc.cfg.TiDB.Vars = map[string]string{
|
||||
"time_zone": "UTC",
|
||||
}
|
||||
err := s.rc.restoreSchema(s.ctx)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
// test after restore schema, sysVars has been updated
|
||||
tz, ok := s.rc.sysVars["time_zone"]
|
||||
c.Assert(ok, IsTrue)
|
||||
c.Assert(tz, Equals, "UTC")
|
||||
}
|
||||
|
||||
func (s *restoreSchemaSuite) TestRestoreSchemaFailed(c *C) {
|
||||
|
||||
@ -83,7 +83,6 @@ func isUnknownSystemVariableErr(err error) bool {
|
||||
}
|
||||
|
||||
func DBFromConfig(ctx context.Context, dsn config.DBStore) (*sql.DB, error) {
|
||||
|
||||
param := common.MySQLConnectParam{
|
||||
Host: dsn.Host,
|
||||
Port: dsn.Port,
|
||||
|
||||
Reference in New Issue
Block a user