Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
remove useless timezone setting
Browse files Browse the repository at this point in the history
  • Loading branch information
glorv committed May 11, 2021
1 parent ef59ee9 commit 7b061e0
Show file tree
Hide file tree
Showing 85 changed files with 7 additions and 180 deletions.
1 change: 0 additions & 1 deletion chaos/cases/conf/task-optimistic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ shard-mode: optimistic
# so ignore sharding table check, seems has no effect on sync-diff-inspector
# see https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html
ignore-checking-items: ["schema_of_shard_tables","auto_increment_ID"] # tables generated by go-sqlsmith may have auto increment ID
timezone: "UTC"

target-database:
host: "tidb-0.tidb"
Expand Down
1 change: 0 additions & 1 deletion chaos/cases/conf/task-pessimistic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ shard-mode: pessimistic
# so ignore sharding table check, seems has no effect on sync-diff-inspector
# see https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html
ignore-checking-items: ["schema_of_shard_tables","auto_increment_ID"] # tables generated by go-sqlsmith may have auto increment ID
timezone: "UTC"

target-database:
host: "tidb-0.tidb"
Expand Down
1 change: 0 additions & 1 deletion chaos/cases/conf/task-single.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
name: "task_single"
task-mode: all
timezone: "UTC"

target-database:
host: "tidb-0.tidb"
Expand Down
27 changes: 1 addition & 26 deletions cmd/dm-syncer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@ package main
import (
"flag"
"fmt"
"os"
"time"

"github.com/BurntSushi/toml"
"github.com/go-mysql-org/go-mysql/mysql"
"github.com/pingcap/errors"
bf "github.com/pingcap/tidb-tools/pkg/binlog-filter"
"github.com/pingcap/tidb-tools/pkg/filter"
router "github.com/pingcap/tidb-tools/pkg/table-router"
"os"

"github.com/pingcap/dm/dm/config"
"github.com/pingcap/dm/pkg/log"
"github.com/pingcap/dm/pkg/utils"
)

Expand Down Expand Up @@ -55,8 +52,6 @@ type commonConfig struct {
SafeMode bool
MaxRetry int

TimezoneStr string

SyncerConfigFormat bool
}

Expand All @@ -77,7 +72,6 @@ func (c *commonConfig) newConfigFromSyncerConfig(args []string) (*config.SubTask
EnableGTID: c.EnableGTID,
SafeMode: c.SafeMode,
MaxRetry: c.MaxRetry,
TimezoneStr: c.TimezoneStr,
}

cfg.FlagSet = flag.NewFlagSet("dm-syncer", flag.ContinueOnError)
Expand All @@ -102,7 +96,6 @@ func (c *commonConfig) newConfigFromSyncerConfig(args []string) (*config.SubTask
fs.BoolVar(&cfg.EnableGTID, "enable-gtid", false, "enable gtid mode")
fs.BoolVar(&cfg.SafeMode, "safe-mode", false, "enable safe mode to make syncer reentrant")
fs.IntVar(&cfg.MaxRetry, "max-retry", 100, "maxinum retry when network interruption")
fs.StringVar(&cfg.TimezoneStr, "timezone", "", "target database timezone location string")
fs.BoolVar(&SyncerConfigFormat, "syncer-config-format", false, "read syncer config format")

if err := fs.Parse(args); err != nil {
Expand Down Expand Up @@ -164,7 +157,6 @@ func (c *commonConfig) newSubTaskConfig(args []string) (*config.SubTaskConfig, e
fs.BoolVar(&cfg.EnableGTID, "enable-gtid", false, "enable gtid mode")
fs.BoolVar(&cfg.SafeMode, "safe-mode", false, "enable safe mode to make syncer reentrant")
fs.IntVar(&cfg.MaxRetry, "max-retry", 100, "maxinum retry when network interruption")
fs.StringVar(&cfg.Timezone, "timezone", "", "target database timezone location string")
fs.StringVar(&cfg.Name, "cp-table-prefix", "dm-syncer", "the prefix of the checkpoint table name")
fs.BoolVar(&syncerConfigFormat, "syncer-config-format", false, "read syncer config format")

Expand All @@ -178,11 +170,6 @@ func (c *commonConfig) newSubTaskConfig(args []string) (*config.SubTaskConfig, e
cfg.ServerID = uint32(serverID)
}

if cfg.Timezone != "" {
log.L().Warn("timezone is deprecated, will auto use UTC instead.")
cfg.Timezone = "+00:00"
}

return cfg, nil
}

Expand All @@ -208,16 +195,8 @@ func newCommonConfig() *commonConfig {
fs.BoolVar(&cfg.EnableGTID, "enable-gtid", false, "enable gtid mode")
fs.BoolVar(&cfg.SafeMode, "safe-mode", false, "enable safe mode to make syncer reentrant")
fs.IntVar(&cfg.MaxRetry, "max-retry", 100, "maxinum retry when network interruption")
fs.StringVar(&cfg.TimezoneStr, "timezone", "", "target database timezone location string")

if cfg.TimezoneStr != "" {
log.L().Warn("timezone is deprecated, will auto use UTC instead.")
cfg.TimezoneStr = "+00:00"
}

fs.BoolVar(&cfg.SyncerConfigFormat, "syncer-config-format", false, "read syncer config format")


return cfg
}

Expand Down Expand Up @@ -278,9 +257,6 @@ type syncerConfig struct {
// MaxDMLConnectionTimeout string `toml:"execute-dml-timeout" json:"execute-dml-timeout"`
// ExecutionQueueLength int `toml:"execute-queue-length" json:"execute-queue-length"`

TimezoneStr string `toml:"timezone" json:"timezone"`
Timezone *time.Location `json:"-"`

printVersion bool
}

Expand Down Expand Up @@ -356,7 +332,6 @@ func (oc *syncerConfig) convertToNewFormat() (*config.SubTaskConfig, error) {
},

ConfigFile: oc.ConfigFile,
Timezone: oc.TimezoneStr,
From: oc.From,
To: oc.To,
}
Expand Down
10 changes: 0 additions & 10 deletions dm/config/subtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ type SubTaskConfig struct {
HeartbeatReportInterval int `toml:"heartbeat-report-interval" json:"heartbeat-report-interval"`
EnableHeartbeat bool `toml:"enable-heartbeat" json:"enable-heartbeat"`
Meta *Meta `toml:"meta" json:"meta"`
// deprecated, will auto adjust source and target time_zone
Timezone string `toml:"timezone" json:"timezone"`

// RelayDir get value from dm-worker config
RelayDir string `toml:"relay-dir" json:"relay-dir"`

Expand Down Expand Up @@ -275,13 +272,6 @@ func (c *SubTaskConfig) Adjust(verifyDecryptPassword bool) error {
c.MetaSchema = defaultMetaSchema
}

if c.Timezone != "" {
_, err := utils.ParseTimeZone(c.Timezone)
if err != nil {
return terror.ErrConfigInvalidTimezone.Delegate(err, c.Timezone)
}
}

dirSuffix := "." + c.Name
if !strings.HasSuffix(c.LoaderConfig.Dir, dirSuffix) { // check to support multiple times calling
// if not ends with the task name, we append the task name to the tail
Expand Down
10 changes: 0 additions & 10 deletions dm/config/subtask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func (t *testConfig) TestSubTask(c *C) {
ShardMode: "optimistic",
SourceID: "mysql-instance-01",
OnlineDDLScheme: "pt",
Timezone: "Asia/Shanghai",
From: DBConfig{
Host: "127.0.0.1",
Port: 3306,
Expand Down Expand Up @@ -74,7 +73,6 @@ func (t *testConfig) TestSubTaskAdjustFail(c *C) {
Name: "test-task",
SourceID: "mysql-instance-01",
OnlineDDLScheme: "pt",
Timezone: "Asia/Shanghai",
From: DBConfig{
Host: "127.0.0.1",
Port: 3306,
Expand Down Expand Up @@ -133,14 +131,6 @@ func (t *testConfig) TestSubTaskAdjustFail(c *C) {
},
"\\[.*\\], Message: online scheme rtc not supported.*",
},
{
func() *SubTaskConfig {
cfg := newSubTaskConfig()
cfg.Timezone = "my-house"
return cfg
},
"\\[.*\\], Message: invalid timezone string: my-house.*",
},
}

for _, tc := range testCases {
Expand Down
9 changes: 0 additions & 9 deletions dm/config/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ type TaskConfig struct {
EnableHeartbeat bool `yaml:"enable-heartbeat" toml:"enable-heartbeat" json:"enable-heartbeat"`
HeartbeatUpdateInterval int `yaml:"heartbeat-update-interval" toml:"heartbeat-update-interval" json:"heartbeat-update-interval"`
HeartbeatReportInterval int `yaml:"heartbeat-report-interval" toml:"heartbeat-report-interval" json:"heartbeat-report-interval"`
// deprecated, needn't set anymore, will always use UTC instead
Timezone string `yaml:"timezone" toml:"timezone" json:"timezone"`

// handle schema/table name mode, and only for schema/table name
// if case insensitive, we would convert schema/table name to lower case
Expand Down Expand Up @@ -595,11 +593,6 @@ func (c *TaskConfig) adjust() error {
return terror.ErrConfigGlobalConfigsUnused.Generate(unusedConfigs)
}

if c.Timezone != "" {
log.L().Warn("timezone config is deprecated, will automatically use UTC instead")
}
c.Timezone = defaultTimeZone

if c.RemoveMeta {
log.L().Warn("`remove-meta` in task config is deprecated, please use `start-task ... --remove-meta` instead")
}
Expand Down Expand Up @@ -631,7 +624,6 @@ func (c *TaskConfig) SubTaskConfigs(sources map[string]DBConfig) ([]*SubTaskConf
}
cfg.HeartbeatUpdateInterval = c.HeartbeatUpdateInterval
cfg.HeartbeatReportInterval = c.HeartbeatReportInterval
cfg.Timezone = c.Timezone
cfg.Meta = inst.Meta

cfg.From = dbCfg
Expand Down Expand Up @@ -709,7 +701,6 @@ func FromSubTaskConfigs(stCfgs ...*SubTaskConfig) *TaskConfig {
c.EnableHeartbeat = stCfg0.EnableHeartbeat
c.HeartbeatUpdateInterval = stCfg0.HeartbeatUpdateInterval
c.HeartbeatReportInterval = stCfg0.HeartbeatReportInterval
c.Timezone = stCfg0.Timezone
c.CaseSensitive = stCfg0.CaseSensitive
c.TargetDB = &stCfg0.To // just ref
c.OnlineDDLScheme = stCfg0.OnlineDDLScheme
Expand Down
14 changes: 0 additions & 14 deletions dm/config/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ name: test
task-mode: all
shard-mode: "pessimistic"
meta-schema: "dm_meta"
timezone: "Asia/Shanghai"
case-sensitive: false
online-ddl-scheme: "gh-ost"
clean-dump-file: true
Expand Down Expand Up @@ -137,7 +136,6 @@ name: test
task-mode: all
shard-mode: "pessimistic"
meta-schema: "dm_meta"
timezone: "Asia/Shanghai"
case-sensitive: false
online-ddl-scheme: "gh-ost"
clean-dump-file: true
Expand Down Expand Up @@ -245,7 +243,6 @@ task-mode: all
is-sharding: true
meta-schema: "dm_meta"
enable-heartbeat: true
timezone: "Asia/Shanghai"
ignore-checking-items: ["all"]
target-database:
Expand All @@ -271,7 +268,6 @@ task-mode: all
is-sharding: true
meta-schema: "dm_meta"
enable-heartbeat: true
timezone: "Asia/Shanghai"
ignore-checking-items: ["all"]
target-database:
Expand Down Expand Up @@ -308,7 +304,6 @@ task-mode: all
is-sharding: true
meta-schema: "dm_meta"
enable-heartbeat: true
timezone: "Asia/Shanghai"
ignore-checking-items: ["all"]
`)
err = ioutil.WriteFile(filepath, configContent, 0o644)
Expand All @@ -325,7 +320,6 @@ task-mode: all
is-sharding: true
meta-schema: "dm_meta"
enable-heartbeat: true
timezone: "Asia/Shanghai"
ignore-checking-items: ["all"]
`)
err = ioutil.WriteFile(filepath, configContent, 0o644)
Expand All @@ -340,7 +334,6 @@ name: test
is-sharding: true
meta-schema: "dm_meta"
enable-heartbeat: true
timezone: "Asia/Shanghai"
ignore-checking-items: ["all"]
`)
err = ioutil.WriteFile(filepath, configContent, 0o644)
Expand All @@ -358,7 +351,6 @@ meta-schema: "dm_meta"
enable-heartbeat: true
heartbeat-update-interval: 1
heartbeat-report-interval: 1
timezone: "Asia/Shanghai"
target-database:
host: "127.0.0.1"
Expand Down Expand Up @@ -436,7 +428,6 @@ meta-schema: "dm_meta"
enable-heartbeat: true
heartbeat-update-interval: 1
heartbeat-report-interval: 1
timezone: "Asia/Shanghai"
target-database:
host: "127.0.0.1"
Expand Down Expand Up @@ -543,7 +534,6 @@ func (t *testConfig) TestGenAndFromSubTaskConfigs(c *C) {
metaSchema = "meta-sub-tasks"
heartbeatUI = 12
heartbeatRI = 21
timezone = "Asia/Shanghai"
maxAllowedPacket = 10244201
fromSession = map[string]string{
"sql_mode": " NO_AUTO_VALUE_ON_ZERO,ANSI_QUOTES",
Expand Down Expand Up @@ -650,7 +640,6 @@ func (t *testConfig) TestGenAndFromSubTaskConfigs(c *C) {
BinLogPos: 456,
BinLogGTID: "1-1-12,4-4-4",
},
Timezone: timezone,
From: source1DBCfg,
To: DBConfig{
Host: "127.0.0.1",
Expand Down Expand Up @@ -719,7 +708,6 @@ func (t *testConfig) TestGenAndFromSubTaskConfigs(c *C) {
EnableHeartbeat: stCfg1.EnableHeartbeat,
HeartbeatUpdateInterval: heartbeatUI,
HeartbeatReportInterval: heartbeatRI,
Timezone: timezone,
CaseSensitive: stCfg1.CaseSensitive,
TargetDB: &stCfg1.To,
MySQLInstances: []*MySQLInstance{
Expand Down Expand Up @@ -812,8 +800,6 @@ func (t *testConfig) TestGenAndFromSubTaskConfigs(c *C) {
c.Assert(stCfg2.EnableHeartbeat, IsTrue)
stCfg1.EnableHeartbeat = false
stCfg2.EnableHeartbeat = false
stCfg1.Timezone = defaultTimeZone
stCfg2.Timezone = defaultTimeZone
c.Assert(stCfgs[0].String(), Equals, stCfg1.String())
c.Assert(stCfgs[1].String(), Equals, stCfg2.String())
}
Expand Down
1 change: 0 additions & 1 deletion dm/dm-ansible/conf/task_advanced.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ meta-schema: "dm_meta" # meta schema in downstreaming database to store meta in
enable-heartbeat: false # whether to enable heartbeat for calculating lag between master and syncer
# heartbeat-update-interval: 1 # interval to do heartbeat and save timestamp, default 1s
# heartbeat-report-interval: 10 # interval to report time lap to prometheus, default 10s
# timezone: "Asia/Shanghai" # target database timezone, all timestamp event in binlog will translate to format time based on this timezone, default use local timezone

target-database:
host: "192.168.0.1"
Expand Down
1 change: 0 additions & 1 deletion dm/dm-ansible/scripts/dm_instances.json
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,6 @@
"30d"
]
},
"timezone": "",
"title": "Test-Cluster-DM-worker-instances",
"uid": "le1FDN_Wz",
"version": 1
Expand Down
1 change: 0 additions & 1 deletion dm/master/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ is-sharding: true
shard-mode: ""
meta-schema: "dm_meta"
enable-heartbeat: true
timezone: "Asia/Shanghai"
ignore-checking-items: ["all"]
target-database:
Expand Down
1 change: 0 additions & 1 deletion dm/master/task_advanced.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ meta-schema: "dm_meta" # meta schema in downstreaming database to store meta in
enable-heartbeat: false # whether to enable heartbeat for calculating lag between master and syncer
# heartbeat-update-interval: 1 # interval to do heartbeat and save timestamp, default 1s
# heartbeat-report-interval: 10 # interval to report time lap to prometheus, default 10s
# timezone: "Asia/Shanghai" # target database timezone, all timestamp event in binlog will translate to format time based on this timezone, default use local timezone

target-database:
host: "192.168.0.1"
Expand Down
4 changes: 0 additions & 4 deletions dm/worker/subtask.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ meta-file = "./syncer.subTaskA.meta"
worker-count = 16
batch = 1000


# target database timezone, all timestamp event in binlog will translate to format time based on this timezone, default use local timezone
# timezone = "Asia/Shanghai"

# filter

# block allow list provides a library to filter replicate on schema/table by given rules
Expand Down
6 changes: 2 additions & 4 deletions dumpling/dumpling.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ func (m *Dumpling) Init(ctx context.Context) error {
var err error
m.dumpConfig, err = m.constructArgs()
m.detectSQLMode(ctx)
if m.cfg.Timezone != "" {
m.dumpConfig.SessionParams["time_zone"] = m.cfg.Timezone
}
m.logger.Info("create dumpling", zap.Stringer("config", m.dumpConfig))
m.dumpConfig.SessionParams["time_zone"] = "+00:00"
m.logger.Info("create dumpling", zap.Stringer("config", m.dumpConfig))
return err
}

Expand Down
4 changes: 1 addition & 3 deletions loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,7 @@ func (l *Loader) Init(ctx context.Context) (err error) {
if lcfg.To.Session == nil {
lcfg.To.Session = make(map[string]string)
}
if lcfg.Timezone != "" {
lcfg.To.Session["time_zone"] = lcfg.Timezone
}
lcfg.To.Session["time_zone"] = "+00:00"

hasSQLMode := false
for k := range l.cfg.To.Session {
Expand Down
Loading

0 comments on commit 7b061e0

Please sign in to comment.