tikv / pd

Placement driver for TiKV
Apache License 2.0
1.03k stars 714 forks source link

rule_list: should we consider a peer should be leader and follower in 2 rules in `checkApplyRules` #8313

Open AndreMouche opened 1 week ago

AndreMouche commented 1 week ago

Bug Report

when we try to add new placement-rule into the cluster, we would use the following function to check whether the new rule has conflictions with some exist rules. https://github.com/tikv/pd/blob/fca469ca33eb5d8b5e0891b507c87709a00b0e81/pkg/schedule/placement/rule_list.go#L27-L46)

however, the above function miss the following corner case, which would save conflict placement-rule in the system:

both zone has only 1 tikv instance and the rule defines as the following: leader should in tikv1, follower should in tikv1, for example:

 CREATE PLACEMENT POLICY leader_follower_in_1 LEADER_CONSTRAINTS="[+zone=bj1]" FOLLOWER_CONSTRAINTS="{+zone=bj1: 1,+zone=bj3: 1}"; 

the above function will return success, while we could never make the replica on tikv1 meet these 2 rules at the same time.