Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd: Make changefeed sort dir visible (#2222) #2239

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cdc/kv/etcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion cdc/model/changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions cdc/model/changefeed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func (s *configSuite) TestFillV1(c *check.C) {
},
StartTs: 417136892416622595,
Engine: "memory",
SortDir: ".",
Config: &config.ReplicaConfig{
CaseSensitive: true,
Filter: &config.FilterConfig{
Expand Down
25 changes: 17 additions & 8 deletions cdc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -424,14 +422,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 {
Expand Down