Skip to content

Commit

Permalink
Make sure to disable sync rep when initializing a primary. (#801)
Browse files Browse the repository at this point in the history
The step to reach the SINGLE state could be done from a pre-existing PGDATA,
such as taken from a backup tool. In that case, the postgresql.auto.conf
might have been installed with a setting that enables synchronous
replication.

Trouble is, we're initializing the first node in the system, and when we
reach the SINGLE state any setup for sync-rep does not make sense, we know
we don't have any secondary available.
  • Loading branch information
DimCitus committed Sep 7, 2021
1 parent c1daadf commit c52ad9c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/bin/pg_autoctl/fsm_transition.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@ fsm_init_primary(Keeper *keeper)
return false;
}

/*
* When dealing with a pg_autoctl create postgres command with a
* pre-existing PGDATA directory, make sure we can start the cluster
* without being in sync-rep already. The target state here is SINGLE
* after all.
*/
if (!fsm_disable_replication(keeper))
{
log_error("Failed to disable synchronous replication in order to "
"initialize as a primary, see above for details");
return false;
}

/*
* FIXME: In the current FSM, I am not sure this can happen anymore. That
* said we might want to remain compatible with initializing a SINGLE from
Expand Down

0 comments on commit c52ad9c

Please sign in to comment.