Skip to content

Commit c52ad9c

Browse files
authored
Make sure to disable sync rep when initializing a primary. (#801)
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.
1 parent c1daadf commit c52ad9c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/bin/pg_autoctl/fsm_transition.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,19 @@ fsm_init_primary(Keeper *keeper)
200200
return false;
201201
}
202202

203+
/*
204+
* When dealing with a pg_autoctl create postgres command with a
205+
* pre-existing PGDATA directory, make sure we can start the cluster
206+
* without being in sync-rep already. The target state here is SINGLE
207+
* after all.
208+
*/
209+
if (!fsm_disable_replication(keeper))
210+
{
211+
log_error("Failed to disable synchronous replication in order to "
212+
"initialize as a primary, see above for details");
213+
return false;
214+
}
215+
203216
/*
204217
* FIXME: In the current FSM, I am not sure this can happen anymore. That
205218
* said we might want to remain compatible with initializing a SINGLE from

0 commit comments

Comments
 (0)