Skip to content

Commit a817326

Browse files
authored
Refrain from preventing changes that are not really changes. (#570)
When a user runs the same command twice in a row, such as with the following, make it so that the second time just works. It didn't because we failed to observe that setting the candidate priority to zero could be a non-changer if that's already the current value of the setting. pg_autoctl set node candidate-priority --name node3 0 We could also skip the operation entirely, but this has two drawbacks: - the client implementation would then need to decide if it has to wait for the apply-settings steps to happen or immediately return, - more importantly, if there's a problem with synchronous_standby_names it might be good that setting a value to its current setting, thus applying no changes, forces a cache invalidation of the primary's setup.
1 parent 2f52925 commit a817326

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/monitor/node_active_protocol.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,8 @@ set_node_candidate_priority(PG_FUNCTION_ARGS)
17221722
ListCell *nodeCell = NULL;
17231723
int nonZeroCandidatePriorityNodeCount = 0;
17241724

1725-
AutoFailoverNode *currentNode = GetAutoFailoverNodeByName(formationId, nodeName);
1725+
AutoFailoverNode *currentNode =
1726+
GetAutoFailoverNodeByName(formationId, nodeName);
17261727

17271728
if (currentNode == NULL)
17281729
{
@@ -1748,7 +1749,7 @@ set_node_candidate_priority(PG_FUNCTION_ARGS)
17481749
MAX_USER_DEFINED_CANDIDATE_PRIORITY)));
17491750
}
17501751

1751-
if (candidatePriority == 0)
1752+
if (candidatePriority == 0 && currentNode->candidatePriority != 0)
17521753
{
17531754
/*
17541755
* We need to ensure we have at least two nodes with a non-zero
@@ -1862,7 +1863,8 @@ set_node_replication_quorum(PG_FUNCTION_ARGS)
18621863
bool replicationQuorum = PG_GETARG_BOOL(2);
18631864

18641865

1865-
AutoFailoverNode *currentNode = GetAutoFailoverNodeByName(formationId, nodeName);
1866+
AutoFailoverNode *currentNode =
1867+
GetAutoFailoverNodeByName(formationId, nodeName);
18661868

18671869
if (currentNode == NULL)
18681870
{

0 commit comments

Comments
 (0)