Skip to content

Commit

Permalink
cmd: add more logs to debug cdc data-dir set up. (#2334) (#2363)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Jul 26, 2021
1 parent 2e43a4c commit e812b60
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cdc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ func (s *Server) initDataDir(ctx context.Context) error {
return errors.Trace(err)
}

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))
log.Info(fmt.Sprintf("%s is set as data-dir (%dGB available), sort-dir=%s. "+
"It is recommended that the disk for data-dir at least have %dGB available space", conf.DataDir, diskInfo.Avail, conf.Sorter.SortDir, dataDirThreshold))

return nil
}
Expand Down
25 changes: 19 additions & 6 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ func loadAndVerifyServerConfig(cmd *cobra.Command) (*config.ServerConfig, error)
if err := strictDecodeFile(serverConfigFilePath, "TiCDC server", conf); err != nil {
return nil, err
}
// user specified sort-dir should not take effect, it's always `/tmp/sorter`
// if user try to set sort-dir by config file, warn it.
if conf.Sorter.SortDir != config.DefaultSortDir {
cmd.Printf(color.HiYellowString("[WARN] --sort-dir is deprecated in server settings. " +
"sort-dir will be set to `{data-dir}/tmp/sorter`. The sort-dir here will be no-op\n"))

conf.Sorter.SortDir = config.DefaultSortDir
}
}
cmd.Flags().Visit(func(flag *pflag.Flag) {
switch flag.Name {
Expand Down Expand Up @@ -187,18 +195,23 @@ func loadAndVerifyServerConfig(cmd *cobra.Command) (*config.ServerConfig, error)
case "cert-allowed-cn":
conf.Security.CertAllowedCN = serverConfig.Security.CertAllowedCN
case "sort-dir":
// user specified sorter dir should not take effect
if serverConfig.Sorter.SortDir != config.DefaultSortDir {
cmd.Printf(color.HiYellowString("[WARN] --sort-dir is deprecated in server settings. " +
"sort-dir will be set to `{data-dir}/tmp/sorter`. The sort-dir here will be no-op\n"))
}
conf.Sorter.SortDir = config.DefaultSortDir
conf.Sorter.SortDir = serverConfig.Sorter.SortDir
case "pd", "config":
// do nothing
default:
log.Panic("unknown flag, please report a bug", zap.String("flagName", flag.Name))
}
})

// user specified sorter dir should not take effect, it's always `/tmp/sorter`
// if user try to set sort-dir by flag, warn it.
if conf.Sorter.SortDir != config.DefaultSortDir {
cmd.Printf(color.HiYellowString("[WARN] --sort-dir is deprecated in server settings. " +
"sort-dir will be set to `{data-dir}/tmp/sorter`. The sort-dir here will be no-op\n"))

conf.Sorter.SortDir = config.DefaultSortDir
}

if err := conf.ValidateAndAdjust(); err != nil {
return nil, errors.Trace(err)
}
Expand Down

0 comments on commit e812b60

Please sign in to comment.