Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit 664d3c1

Browse files
author
Philipp Heckel
committed
Re-read master after recovery to limit re-triggering
1 parent 370e9d3 commit 664d3c1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

go/logic/topology_recovery.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,8 +1545,34 @@ func recoverSemiSyncReplicas(topologyRecovery *TopologyRecovery, analysisEntry i
15451545
}
15461546
}
15471547

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+
15481573
resolveRecovery(topologyRecovery, masterInstance)
15491574
AuditTopologyRecovery(topologyRecovery, fmt.Sprintf("semi-sync: recovery complete; success = %t", topologyRecovery.IsSuccessful))
1575+
15501576
return true, topologyRecovery, nil
15511577
}
15521578

0 commit comments

Comments
 (0)