Skip to content

Commit ef5cc74

Browse files
authored
Attempt at fixing an often failing test. (#696)
When trying to find if a candidate has already been selected, avoid choosing a node that is in WAIT_PRIMARY. As we don't change the state of such a node when it becomes unhealthy, that might lead to strange results when two failover situations happen one after another. Also guard demoted to cachingup transitions to only happen when the current primary is known healthy.
1 parent e7e33bc commit ef5cc74

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

src/monitor/group_state_machine.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ ProceedGroupState(AutoFailoverNode *activeNode)
633633
* concurrently making progress.
634634
*/
635635
if (IsCurrentState(activeNode, REPLICATION_STATE_DEMOTED) &&
636+
IsHealthy(primaryNode) &&
636637
((primaryNode->reportedState == REPLICATION_STATE_WAIT_PRIMARY ||
637638
primaryNode->reportedState == REPLICATION_STATE_JOIN_PRIMARY) &&
638639
primaryNode->goalState == REPLICATION_STATE_PRIMARY))
@@ -658,6 +659,7 @@ ProceedGroupState(AutoFailoverNode *activeNode)
658659
* demoted -> catchingup
659660
*/
660661
if (IsCurrentState(activeNode, REPLICATION_STATE_DEMOTED) &&
662+
IsHealthy(primaryNode) &&
661663
(IsCurrentState(primaryNode, REPLICATION_STATE_JOIN_PRIMARY) ||
662664
IsCurrentState(primaryNode, REPLICATION_STATE_WAIT_PRIMARY) ||
663665
IsCurrentState(primaryNode, REPLICATION_STATE_PRIMARY)))

src/monitor/node_metadata.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,11 +1565,7 @@ IsBeingPromoted(AutoFailoverNode *node)
15651565

15661566
(node->reportedState == REPLICATION_STATE_STOP_REPLICATION &&
15671567
(node->goalState == REPLICATION_STATE_STOP_REPLICATION ||
1568-
node->goalState == REPLICATION_STATE_WAIT_PRIMARY)) ||
1569-
1570-
(node->reportedState == REPLICATION_STATE_WAIT_PRIMARY &&
1571-
(node->goalState == REPLICATION_STATE_WAIT_PRIMARY ||
1572-
node->goalState == REPLICATION_STATE_PRIMARY)));
1568+
node->goalState == REPLICATION_STATE_WAIT_PRIMARY)));
15731569
}
15741570

15751571

0 commit comments

Comments
 (0)