Skip to content

Commit 3d50d67

Browse files
authored
Set candidate priority without waiting for state changes in more cases. (#756)
When dropping the last node with candidate priority greater than zero, we might want to change the candidate priority of the last remaining node. The client-side implementation of the command would wait for the APPLY_SETTINGS cycle in some cases with dropped nodes, which is unfortunate: this PR fixes that.
1 parent c962167 commit 3d50d67

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/bin/pg_autoctl/cli_get_set_properties.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -668,22 +668,27 @@ static bool
668668
set_node_candidate_priority(Keeper *keeper, int candidatePriority)
669669
{
670670
KeeperConfig *config = &(keeper->config);
671-
NodeAddressArray nodesArray = { 0 };
671+
CurrentNodeStateArray nodesArray = { 0 };
672672

673673
/*
674674
* There might be some race conditions here, but it's all to be
675675
* user-friendly so in the worst case we're going to be less friendly that
676676
* we could have.
677677
*/
678-
if (!monitor_get_nodes(&(keeper->monitor),
679-
config->formation,
680-
config->groupId,
681-
&nodesArray))
678+
if (!monitor_get_current_state(&(keeper->monitor),
679+
config->formation,
680+
config->groupId,
681+
&nodesArray))
682682
{
683683
/* ignore the error, just don't wait in that case */
684-
log_warn("Failed to get_nodes() on the monitor");
684+
log_warn("Failed to get the list of all the nodes in formation \"%s\" "
685+
"from the monitor, see above for details",
686+
keeper->config.formation);
685687
}
686688

689+
/* ignore the result of the filtering, worst case we don't wait */
690+
(void) nodestateFilterArrayGroup(&nodesArray, config->name);
691+
687692
/* listen for state changes BEFORE we apply new settings */
688693
if (nodesArray.count > 1)
689694
{

src/bin/pg_autoctl/pgsql.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,7 @@ pgsql_execute_with_params(PGSQL *pgsql, const char *sql, int paramCount,
10771077
* with a badly formed SQL query etc.
10781078
*/
10791079
if (pgsql->connectionType == PGSQL_CONN_MONITOR &&
1080+
sqlstate != NULL &&
10801081
!(strcmp(sqlstate, ERRCODE_INVALID_OBJECT_DEFINITION) == 0 ||
10811082
strcmp(sqlstate, ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE) == 0 ||
10821083
strcmp(sqlstate, ERRCODE_OBJECT_IN_USE) == 0 ||

0 commit comments

Comments
 (0)