diff --git a/cdc/kv/etcd_test.go b/cdc/kv/etcd_test.go index 10059635adc..569a7953c3f 100644 --- a/cdc/kv/etcd_test.go +++ b/cdc/kv/etcd_test.go @@ -225,6 +225,7 @@ func (s *etcdSuite) TestOpChangeFeedDetail(c *check.C) { ctx := context.Background() detail := &model.ChangeFeedInfo{ SinkURI: "root@tcp(127.0.0.1:3306)/mysql", + SortDir: "/old-version/sorter", } cfID := "test-op-cf" @@ -236,6 +237,7 @@ func (s *etcdSuite) TestOpChangeFeedDetail(c *check.C) { d, err := s.client.GetChangeFeedInfo(ctx, cfID) c.Assert(err, check.IsNil) c.Assert(d.SinkURI, check.Equals, detail.SinkURI) + c.Assert(d.SortDir, check.Equals, detail.SortDir) err = s.client.LeaseGuardDeleteChangeFeedInfo(ctx, cfID, sess.Lease()) c.Assert(err, check.IsNil) diff --git a/cdc/model/changefeed.go b/cdc/model/changefeed.go index 444dce38095..d8bcb48230b 100644 --- a/cdc/model/changefeed.go +++ b/cdc/model/changefeed.go @@ -78,7 +78,9 @@ type ChangeFeedInfo struct { AdminJobType AdminJobType `json:"admin-job-type"` Engine SortEngine `json:"sort-engine"` // SortDir is deprecated - SortDir string `json:"-"` + // it cannot be set by user in changefeed level, any assignment to it should be ignored. + // but can be fetched for backward compatibility + SortDir string `json:"sort-dir"` Config *config.ReplicaConfig `json:"config"` State FeedState `json:"state"` diff --git a/cdc/model/changefeed_test.go b/cdc/model/changefeed_test.go index c58bf67343f..ff7f0a3e2b4 100644 --- a/cdc/model/changefeed_test.go +++ b/cdc/model/changefeed_test.go @@ -120,6 +120,7 @@ func (s *configSuite) TestFillV1(c *check.C) { }, StartTs: 417136892416622595, Engine: "memory", + SortDir: ".", Config: &config.ReplicaConfig{ CaseSensitive: true, Filter: &config.FilterConfig{ diff --git a/cdc/server.go b/cdc/server.go index 4a5747d1232..c4849c40eb0 100644 --- a/cdc/server.go +++ b/cdc/server.go @@ -375,10 +375,8 @@ func (s *Server) initDataDir(ctx context.Context) error { return errors.Trace(err) } - if diskInfo.Avail < dataDirThreshold { - log.Warn(fmt.Sprintf("%s is set as data-dir (%dGB available), ticdc recommend disk for data-dir "+ - "at least have %dGB available space", conf.DataDir, diskInfo.Avail, dataDirThreshold)) - } + log.Info(fmt.Sprintf("%s is set as data-dir (%dGB available), ticdc recommend disk for data-dir "+ + "at least have %dGB available space", conf.DataDir, diskInfo.Avail, dataDirThreshold)) return nil } @@ -441,14 +439,25 @@ func (s *Server) setUpDataDir(ctx context.Context) error { // at the moment, only consider available disk space func findBestDataDir(candidates []string) (result string, ok bool) { var low uint64 = 0 - for _, dir := range candidates { + + checker := func(dir string) (*util.DiskInfo, error) { + if err := os.MkdirAll(dir, 0o755); err != nil { + return nil, err + } if err := util.IsDirReadWritable(dir); err != nil { - log.Warn("try to get disk info failed", zap.String("dir", dir), zap.Error(err)) - continue + return nil, err } info, err := util.GetDiskInfo(dir) if err != nil { - log.Warn("try to get disk info failed", zap.String("dir", dir), zap.Error(err)) + return nil, err + } + return info, err + } + + for _, dir := range candidates { + info, err := checker(dir) + if err != nil { + log.Warn("check the availability of dir", zap.String("dir", dir), zap.Error(err)) continue } if info.Avail > low {