Skip to content

Commit

Permalink
remove 'runAsDaemon' config for tiflash
Browse files Browse the repository at this point in the history
  • Loading branch information
hehechen committed Dec 14, 2021
1 parent 3f0c568 commit 6e261e8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion components/playground/instance/tiflash.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (inst *TiFlashInstance) checkConfig(deployDir, clusterManagerPath string, v
return errors.Trace(err)
}
defer cf2.Close()
if err := writeTiFlashConfig(cf, inst.TCPPort, inst.Port, inst.ServicePort, inst.StatusPort,
if err := writeTiFlashConfig(cf, version, inst.TCPPort, inst.Port, inst.ServicePort, inst.StatusPort,
inst.Host, deployDir, clusterManagerPath, tidbStatusAddrs, endpoints); err != nil {
return errors.Trace(err)
}
Expand Down
30 changes: 22 additions & 8 deletions components/playground/instance/tiflash_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,18 @@ import (
"fmt"
"io"
"strings"

"github.com/pingcap/tiup/pkg/utils"
"golang.org/x/mod/semver"
)

const tiflashDaemonConfig = `
[application]
runAsDaemon = true
`

const tiflashConfig = `
default_profile = "default"
display_name = "TiFlash"
Expand All @@ -28,10 +38,7 @@ mark_cache_size = 5368709120
path = "%[5]s"
tcp_port = %[3]d
tmp_path = "%[6]s"
[application]
runAsDaemon = true
%[13]s
[flash]
service_addr = "%[10]s:%[8]d"
tidb_status_addr = "%[11]s"
Expand Down Expand Up @@ -90,14 +97,21 @@ quota = "default"
ip = "::/0"
`

func writeTiFlashConfig(w io.Writer, tcpPort, httpPort, servicePort, metricsPort int, ip, deployDir, clusterManagerPath string, tidbStatusAddrs, endpoints []string) error {
func writeTiFlashConfig(w io.Writer, version utils.Version, tcpPort, httpPort, servicePort, metricsPort int, ip, deployDir, clusterManagerPath string, tidbStatusAddrs, endpoints []string) error {
pdAddrs := strings.Join(endpoints, ",")
dataDir := fmt.Sprintf("%s/data", deployDir)
tmpDir := fmt.Sprintf("%s/tmp", deployDir)
logDir := fmt.Sprintf("%s/log", deployDir)
conf := fmt.Sprintf(tiflashConfig, pdAddrs, httpPort, tcpPort,
deployDir, dataDir, tmpDir, logDir, servicePort, metricsPort,
ip, strings.Join(tidbStatusAddrs, ","), clusterManagerPath)
var conf string
if semver.Compare(version.String(), "v5.4.0") >= 0 || version.IsNightly() {
conf = fmt.Sprintf(tiflashConfig, pdAddrs, httpPort, tcpPort,
deployDir, dataDir, tmpDir, logDir, servicePort, metricsPort,
ip, strings.Join(tidbStatusAddrs, ","), clusterManagerPath, "")
} else {
conf = fmt.Sprintf(tiflashConfig, pdAddrs, httpPort, tcpPort,
deployDir, dataDir, tmpDir, logDir, servicePort, metricsPort,
ip, strings.Join(tidbStatusAddrs, ","), clusterManagerPath, tiflashDaemonConfig)
}
_, err := w.Write([]byte(conf))
return err
}
3 changes: 0 additions & 3 deletions pkg/cluster/ansible/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ path = "/data1/test-cluster/leiysky-ansible-test-deploy/tiflash/data/db"
tcp_port = 11315
tmp_path = "/data1/test-cluster/leiysky-ansible-test-deploy/tiflash/data/db/tmp"
[application]
runAsDaemon = true
[flash]
service_addr = "172.16.5.85:11317"
tidb_status_addr = "172.16.5.85:11310"
Expand Down
12 changes: 10 additions & 2 deletions pkg/cluster/spec/tiflash.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ func (i *TiFlashInstance) initTiFlashConfig(cfg *scripts.TiFlashScript, clusterV
pathConfig string
isStorageDirsDefined bool
deprecatedUsersConfig string
daemonConfig string
err error
)
if isStorageDirsDefined, err = checkTiFlashStorageConfigWithVersion(clusterVersion, src); err != nil {
Expand Down Expand Up @@ -438,6 +439,13 @@ func (i *TiFlashInstance) initTiFlashConfig(cfg *scripts.TiFlashScript, clusterV
}

topo := Specification{}

if semver.Compare(clusterVersion, "v5.4.0") >= 0 || utils.Version(clusterVersion).IsNightly() {
// For 5.4.0 or later, TiFlash can ignore application.runAsDaemon setting
daemonConfig = "#"
} else {
daemonConfig = `application.runAsDaemon: true`
}
err = yaml.Unmarshal([]byte(fmt.Sprintf(`
server_configs:
tiflash:
Expand All @@ -463,12 +471,12 @@ server_configs:
logger.count: 20
logger.level: "debug"
logger.size: "1000M"
application.runAsDaemon: true
%[13]s
raft.pd_addr: "%[9]s"
profiles.default.max_memory_usage: 0
%[12]s
`, pathConfig, cfg.LogDir, cfg.TCPPort, cfg.HTTPPort, cfg.TiDBStatusAddrs, cfg.IP, cfg.FlashServicePort,
cfg.StatusPort, cfg.PDAddrs, cfg.DeployDir, cfg.TmpDir, deprecatedUsersConfig)), &topo)
cfg.StatusPort, cfg.PDAddrs, cfg.DeployDir, cfg.TmpDir, deprecatedUsersConfig, daemonConfig)), &topo)

if err != nil {
return nil, err
Expand Down

0 comments on commit 6e261e8

Please sign in to comment.