Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#5476
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
D3Hunter authored and ti-chi-bot committed May 19, 2022
1 parent 2f363f6 commit 3723033
Show file tree
Hide file tree
Showing 4 changed files with 507 additions and 5 deletions.
19 changes: 16 additions & 3 deletions dm/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ import (
"github.com/pingcap/tidb/parser/format"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/sessionctx"
<<<<<<< HEAD
=======
"github.com/pingcap/tidb/util/dbutil"
"github.com/pingcap/tidb/util/filter"
regexprrouter "github.com/pingcap/tidb/util/regexpr-router"
router "github.com/pingcap/tidb/util/table-router"
>>>>>>> 6148c45ab (dm: parse start-time using upstream timezone (#5476))
clientv3 "go.etcd.io/etcd/client/v3"
"go.uber.org/atomic"
"go.uber.org/zap"
Expand All @@ -51,6 +58,7 @@ import (
"github.com/pingcap/tiflow/dm/pkg/conn"
tcontext "github.com/pingcap/tiflow/dm/pkg/context"
fr "github.com/pingcap/tiflow/dm/pkg/func-rollback"
"github.com/pingcap/tiflow/dm/pkg/gtid"
"github.com/pingcap/tiflow/dm/pkg/ha"
"github.com/pingcap/tiflow/dm/pkg/log"
parserpkg "github.com/pingcap/tiflow/dm/pkg/parser"
Expand Down Expand Up @@ -182,7 +190,8 @@ type Syncer struct {
// the status of this track may change over time.
safeMode *sm.SafeMode

timezone *time.Location
upstreamTZ *time.Location
timezone *time.Location

binlogSizeCount atomic.Int64
lastBinlogSizeCount atomic.Int64
Expand Down Expand Up @@ -336,6 +345,10 @@ func (s *Syncer) Init(ctx context.Context) (err error) {
}()

tctx := s.tctx.WithContext(ctx)
s.upstreamTZ, err = str2TimezoneOrFromDB(tctx, "", &s.cfg.From)
if err != nil {
return
}
s.timezone, err = str2TimezoneOrFromDB(tctx, s.cfg.Timezone, &s.cfg.To)
if err != nil {
return
Expand Down Expand Up @@ -3916,9 +3929,9 @@ func (s *Syncer) flushOptimisticTableInfos(tctx *tcontext.Context) {

func (s *Syncer) setGlobalPointByTime(tctx *tcontext.Context, timeStr string) error {
// we support two layout
t, err := time.ParseInLocation(config.StartTimeFormat, timeStr, s.timezone)
t, err := time.ParseInLocation(config.StartTimeFormat, timeStr, s.upstreamTZ)
if err != nil {
t, err = time.ParseInLocation(config.StartTimeFormat2, timeStr, s.timezone)
t, err = time.ParseInLocation(config.StartTimeFormat2, timeStr, s.upstreamTZ)
}
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion dm/syncer/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ func str2TimezoneOrFromDB(tctx *tcontext.Context, tzStr string, dbCfg *config.DB
if err != nil {
return nil, err
}
tctx.L().Info("use timezone", zap.String("location", loc.String()))
tctx.L().Info("use timezone", zap.String("location", loc.String()),
zap.String("host", dbCfg.Host), zap.Int("port", dbCfg.Port))
return loc, nil
}

Expand Down
Loading

0 comments on commit 3723033

Please sign in to comment.