How pd schedules regions
- Store : each tikv server maps to a store
- Pending: learner/follower log lags behind leader by a large margin
-
PD use standard revision + lease for leader failover
- Scheduler: generate the operator, which encapsulates the steps related to rebalancing for a single region,i.e., one region has mutliple steps
- balance-leader-scheduler
- balance-region-scheduler
- hot-region-scheduler
type Scheduler interface {
GetName() string
GetResourceKind() ResourceKind
Schedule(cluster *clusterInfo) Operator
}
After operator is generated, it will be put in a queue and execute sequentially (possibly in parallel), by sending the operator step to the region leader as a response to the heartbeat
- It will wait for timeout with ack
type Operator interface {
GetRegionID() uint64
GetResourceKind() ResourceKind
Do(region *regionInfo) (*pdpb.RegionHeartbeatResponse, bool)
}