diff --git a/pkg/manager/member/pd_scaler.go b/pkg/manager/member/pd_scaler.go index 1fe1379dd4..47eec74b36 100644 --- a/pkg/manager/member/pd_scaler.go +++ b/pkg/manager/member/pd_scaler.go @@ -56,6 +56,11 @@ func (psd *pdScaler) ScaleOut(tc *v1alpha1.TidbCluster, oldSet *apps.StatefulSet return fmt.Errorf("TidbCluster: %s/%s's pd status sync failed,can't scale out now", ns, tcName) } + if len(tc.Status.PD.FailureMembers) != 0 { + increaseReplicas(newSet, oldSet) + return nil + } + var i int32 = 0 healthCount := 0 totalCount := *oldSet.Spec.Replicas diff --git a/pkg/manager/member/pd_scaler_test.go b/pkg/manager/member/pd_scaler_test.go index 387d7f7c3c..520f58382f 100644 --- a/pkg/manager/member/pd_scaler_test.go +++ b/pkg/manager/member/pd_scaler_test.go @@ -139,6 +139,26 @@ func TestPDScalerScaleOut(t *testing.T) { err: true, changed: false, }, + { + name: "failover now", + update: func(tc *v1alpha1.TidbCluster) { + normalPDMember(tc) + podName := ordinalPodName(v1alpha1.PDMemberType, tc.GetName(), 0) + tc.Status.PD.FailureMembers = map[string]v1alpha1.PDFailureMember{ + podName: {PodName: podName}, + } + pd := tc.Status.PD.Members[podName] + pd.Health = false + tc.Status.PD.Members[podName] = pd + }, + pdUpgrading: false, + hasPVC: true, + hasDeferAnn: true, + pvcDeleteErr: false, + statusSyncFailed: false, + err: false, + changed: true, + }, { name: "don't have members", update: func(tc *v1alpha1.TidbCluster) {