@@ -1545,8 +1545,34 @@ func recoverSemiSyncReplicas(topologyRecovery *TopologyRecovery, analysisEntry i
1545
1545
}
1546
1546
}
1547
1547
1548
+ // Wait for replica count to match desired wait count (this is what triggers the recovery)
1549
+ AuditTopologyRecovery (topologyRecovery , "semi-sync: waiting for desired state:" )
1550
+ success := false
1551
+ for i := 0 ; i < 10 ; i ++ {
1552
+ masterInstance , err = inst .ReadTopologyInstance (& analysisEntry .AnalyzedInstanceKey )
1553
+ if err != nil {
1554
+ return true , topologyRecovery , fmt .Errorf ("error re-reading master instance: %s" , err .Error ())
1555
+ }
1556
+ if exactReplicaTopology {
1557
+ AuditTopologyRecovery (topologyRecovery , fmt .Sprintf ("semi-sync: - current semi-sync replica count = %d, desired semi-sync replica count = %d" , masterInstance .SemiSyncMasterClients , masterInstance .SemiSyncMasterWaitForReplicaCount ))
1558
+ success = masterInstance .SemiSyncMasterWaitForReplicaCount == masterInstance .SemiSyncMasterClients
1559
+ } else {
1560
+ AuditTopologyRecovery (topologyRecovery , fmt .Sprintf ("semi-sync: - current semi-sync replica count = %d, desired semi-sync replica count >= %d" , masterInstance .SemiSyncMasterClients , masterInstance .SemiSyncMasterWaitForReplicaCount ))
1561
+ success = masterInstance .SemiSyncMasterWaitForReplicaCount >= masterInstance .SemiSyncMasterClients
1562
+ }
1563
+ if success {
1564
+ break
1565
+ }
1566
+ time .Sleep (time .Second )
1567
+ }
1568
+ if ! success {
1569
+ AuditTopologyRecovery (topologyRecovery , "semi-sync: timed out waiting for desired state" )
1570
+ return true , topologyRecovery , fmt .Errorf ("timed out waiting for desired state" )
1571
+ }
1572
+
1548
1573
resolveRecovery (topologyRecovery , masterInstance )
1549
1574
AuditTopologyRecovery (topologyRecovery , fmt .Sprintf ("semi-sync: recovery complete; success = %t" , topologyRecovery .IsSuccessful ))
1575
+
1550
1576
return true , topologyRecovery , nil
1551
1577
}
1552
1578
0 commit comments