tikv / pd

Placement driver for TiKV
Apache License 2.0
1.04k stars 719 forks source link

Failed to parse store-limit related configurations in PD config #5497

Open hanlins opened 2 years ago

hanlins commented 2 years ago

Bug Report

What did you do?

Used following config for PD:

[schedule.store-limit.144]
add-peer = 30.0
remove-peer = 30.0

PD paniced parsing the config:

➜  ~ kubectl -n demo logs -f basic-pd-0

Name:      basic-pd-0.basic-pd-peer.demo.svc
Address 1: 10.244.0.31 basic-pd-0.basic-pd-peer.demo.svc.cluster.local
nslookup domain basic-pd-0.basic-pd-peer.demo.svc.svc success
starting pd-server ...
/pd-server --data-dir=/var/lib/pd --name=basic-pd-0 --peer-urls=http://0.0.0.0:2380/ --advertise-peer-urls=http://basic-pd-0.basic-pd-peer.demo.svc:2380/ --client-urls=http://0.0.0.0:2379/ --advertise-client-urls=http://basic-pd-0.basic-pd-peer.demo.svc:2379/ --config=/etc/pd/pd.toml
panic: reflect: call of reflect.Value.SetString on uint64 Value

goroutine 1 [running]:
reflect.flag.mustBe(...)
    /usr/local/go/src/reflect/value.go:221
reflect.Value.SetString(0x23e94e0, 0xc0005485b0, 0x18b, 0xc00055017e, 0x3)
    /usr/local/go/src/reflect/value.go:1747 +0xfa
github.com/BurntSushi/toml.(*MetaData).unifyMap(0xc0015a7a10, 0x2484560, 0xc00053e2d0, 0x24865a0, 0xc000143288, 0x195, 0xc0015a7228, 0xc11b6c)
    /nfs/cache/mod/github.com/!burnt!sushi/toml@v0.3.1/decode.go:301 +0x119
github.com/BurntSushi/toml.(*MetaData).unify(0xc0015a7a10, 0x2484560, 0xc00053e2d0, 0x24865a0, 0xc000143288, 0x195, 0x1, 0x2)
    /nfs/cache/mod/github.com/!burnt!sushi/toml@v0.3.1/decode.go:211 +0x845
github.com/BurntSushi/toml.(*MetaData).unifyStruct(0xc0015a7a10, 0x2484560, 0xc00053e2a0, 0x26fe2a0, 0xc000143200, 0x199, 0x22f1463, 0x0)
    /nfs/cache/mod/github.com/!burnt!sushi/toml@v0.3.1/decode.go:265 +0x676
github.com/BurntSushi/toml.(*MetaData).unify(0xc0015a7a10, 0x2484560, 0xc00053e2a0, 0x26fe2a0, 0xc000143200, 0x199, 0x0, 0x1)
    /nfs/cache/mod/github.com/!burnt!sushi/toml@v0.3.1/decode.go:209 +0x8d4
github.com/BurntSushi/toml.(*MetaData).unifyStruct(0xc0015a7a10, 0x2484560, 0xc00053e210, 0x2708f80, 0xc000143080, 0x199, 0x7f4beffd1d08, 0xc0015a7860)
    /nfs/cache/mod/github.com/!burnt!sushi/toml@v0.3.1/decode.go:265 +0x676
github.com/BurntSushi/toml.(*MetaData).unify(0xc0015a7a10, 0x2484560, 0xc00053e210, 0x2708f80, 0xc000143080, 0x199, 0x0, 0x0)
    /nfs/cache/mod/github.com/!burnt!sushi/toml@v0.3.1/decode.go:209 +0x8d4
github.com/BurntSushi/toml.Decode(0xc000550140, 0x43, 0x26352a0, 0xc000143080, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /nfs/cache/mod/github.com/!burnt!sushi/toml@v0.3.1/decode.go:123 +0x3dd
github.com/BurntSushi/toml.DecodeFile(0x7ffc434f042e, 0xf, 0x26352a0, 0xc000143080, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /nfs/cache/mod/github.com/!burnt!sushi/toml@v0.3.1/decode.go:133 +0x169
github.com/tikv/pd/server/config.(*Config).configFromFile(0xc000143080, 0x7ffc434f042e, 0xf, 0x7, 0x0, 0x0)
    /home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/pd/server/config/config.go:621 +0xb2
github.com/tikv/pd/server/config.(*Config).Parse(0xc000143080, 0xc00003c090, 0x7, 0x7, 0x0, 0x0)
    /home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/pd/server/config/config.go:378 +0x29f
main.main()
    /home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/pd/cmd/pd-server/main.go:44 +0xa5

What did you expect to see?

Should either consume the config or emit an error saying which part of the config is incorrect. pd-ctl can tune the store-limit config, so should config file.

What did you see instead?

PD paniced.

What version of PD are you using (pd-server -V)?

First found the issue in v5.2.0, but tested in top-of-tree (i.e. v6.1.1), the issue still exist.

ChenPeng2013 commented 2 years ago

/severity minor