pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
37.04k stars 5.82k forks source link

TiFlash should support location awareness #21217

Open ilovesoup opened 3 years ago

ilovesoup commented 3 years ago

Feature Request

TiFlash currently does not support location awareness. According to TiKV, it support PD schedule aware of location label reported and avoid schedule replicas of same region to the same location (node, rack or DC). Although TiFlash support single instance multiple disks but it still need rack and DC awareness.

Describe the feature you'd like: Just like in TiKV, TiFlash should use the same label rules to config and report to PD, and PD should follow the same rules to schedule replicas.

solotzg commented 3 years ago

PD show Error Failed to set config: [400] "cannot update LocationLabels when placement rules feature is enabled, please update rule instead" if set location labels by pd-ctrl directly.

solotzg commented 3 years ago

To use location labels for tiflash, we should follow these steps:

tiflash node 2 [server.labels] zone = "z2"

tiflash node 3 [server.labels] zone = "z1"

- Use ddl `ALTER TABLE table_name SET TIFLASH REPLICA count LOCATION LABELS location_labels` like `alter table test.orders set tiflash replica 2 location labels "zone"`. 
- Finally, PD will reschedule region peer and region count of each tiflash store will be like

tiflash node 1 region_count: 14

tiflash node 2 region_count: 28

tiflash node 3 region_count: 14



https://docs.google.com/document/d/1mWQLS7iSrGPXNuBERaOMB_FuL92LUZfkB2Zi3WWFBtY
solotzg commented 2 years ago

/assign @ilovesoup