tiup icon indicating copy to clipboard operation
tiup copied to clipboard

should remove tidb /info key in PD(etcd) after scale-in TiDB

Open crazycs520 opened this issue 3 years ago • 2 comments

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?

topo.yaml

pd_servers:
  - host: 10.0.1.9

tikv_servers:
  - host: 10.0.1.9

tidb_servers:
  - host: 10.0.1.9
  1. Deploy a tidb cluster.
tiup cluster deploy dev nightly topo.yaml 
tiup cluster start dev
  1. After deploy tidb cluster, you can use etcdctl to find the topology information in PD(etcd).
▶ etcdctl --endpoints=10.0.1.9:2379 get "/topology/tidb" --prefix
/topology/tidb/10.0.1.9:4000/info
{"version":"v5.5.0-alpha","git_hash":"adcaaa5cbe1058da8f363c173521929405d0ecb6","ip":"10.0.1.9","status_port":10080,"deploy_path":"/home/tidb/deploy/tidb-4000/bin","start_timestamp":1644481689,"labels":{}}
/topology/tidb/10.0.1.9:4000/ttl
1644481749835274163

You can see there are 2 keys in PD(etcd), those 2 keys are written into PD(etcd) by TiDB itself.

  • /topology/tidb/10.0.1.9:4000/info
  • /topology/tidb/10.0.1.9:4000/ttl
  1. Now, scale-in tidb.
tiup cluster scale-in dev -N 10.0.1.9:4000
  1. Now, use etcdctl to find the topology information in PD(etcd) again:
▶ etcdctl --endpoints=10.0.1.9:2379 get "/topology/tidb" --prefix
/topology/tidb/10.0.1.9:4000/info
{"version":"v5.5.0-alpha","git_hash":"adcaaa5cbe1058da8f363c173521929405d0ecb6","ip":"10.0.1.9","status_port":10080,"deploy_path":"/home/tidb/deploy/tidb-4000/bin","start_timestamp":1644481689,"labels":{}}

As you can see, /topology/tidb/10.0.1.9:4000/info is still in PD(etcd), it's unexpected. /topology/tidb/10.0.1.9:4000/ttl key has been auto delete after ttl timeout.

/topology/tidb/10.0.1.9:4000/info should be deleted after TiDB is been scale-in.

What I expected?

TiUP should remove following keys in PD(etcd) when tidb and ngm were been scale-in.

  • /topology/xxx/10.0.1.9:4000/info
  • /topology/xxx/10.0.1.9:4000/ttl

Other consideration

Since /topology/tidb/10.0.1.9:4000/info and /topology/tidb/10.0.1.9:4000/ttl are written into PD(etcd) by TiDB itself, so let TiUP to delete those key maybe look weird. Maybe let TiUP to write and delte those keys is better.

  1. What version of TiUP are you using (tiup --version)?
▶ tiup --version
1.8.2 tiup
Go Version: go1.17.5
Git Ref: v1.8.2
GitHash: a2912cf0470d651ce724e6c4e79871ec772abe38

crazycs520 avatar Feb 10 '22 08:02 crazycs520

@nexustar PTAL

crazycs520 avatar Feb 10 '22 09:02 crazycs520