From d4de166658444923bbf032114ad8056046a50a38 Mon Sep 17 00:00:00 2001 From: nexustar Date: Mon, 22 Nov 2021 13:07:49 +0800 Subject: [PATCH] playground: add data-dir to ticdc (#1631) --- components/playground/instance/ticdc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/playground/instance/ticdc.go b/components/playground/instance/ticdc.go index 4d41d4db6f..db2a8a36b7 100644 --- a/components/playground/instance/ticdc.go +++ b/components/playground/instance/ticdc.go @@ -20,6 +20,7 @@ import ( "strings" "github.com/pingcap/tiup/pkg/utils" + "golang.org/x/mod/semver" ) // TiCDC represent a ticdc instance. @@ -59,6 +60,15 @@ func (c *TiCDC) Start(ctx context.Context, version utils.Version) error { fmt.Sprintf("--pd=%s", strings.Join(endpoints, ",")), fmt.Sprintf("--log-file=%s", c.LogFile()), } + clusterVersion := string(version) + if semver.Compare(clusterVersion, "v4.0.13") >= 0 { + if (semver.Major(clusterVersion) == "v4" && semver.Compare(clusterVersion, "v4.0.14") >= 0) || + (semver.Major(clusterVersion) == "v5" && semver.Compare(clusterVersion, "v5.0.3") >= 0) { + args = append(args, fmt.Sprintf("--data-dir=%s", filepath.Join(c.Dir, "data"))) + } else { + args = append(args, fmt.Sprintf("--sort-dir=%s/tmp/sorter", filepath.Join(c.Dir, "data"))) + } + } var err error if c.Process, err = NewComponentProcess(ctx, c.Dir, c.BinPath, "cdc", version, args...); err != nil {