From cb764b180dece2f3bf33543712542c49cb1ef704 Mon Sep 17 00:00:00 2001 From: Jaime Casanova Date: Mon, 3 Oct 2011 14:04:27 -0500 Subject: [PATCH] Let the clone happen in a session with synchronous_commit off. This is because in pg 9.1 the default configuration can easily allow sync rep to be activated even if no standby is present and will block pg_start_backup() and pg_stop_backup() in that case. --- repmgr.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/repmgr.c b/repmgr.c index 9fda4f2a..625d116d 100644 --- a/repmgr.c +++ b/repmgr.c @@ -896,6 +896,20 @@ do_standby_clone(void) log_notice(_("Starting backup...\n")); + /* + * in pg 9.1 default is to wait for a sync standby to ack, + * avoid that by turning off sync rep for this session + */ + sqlquery_snprintf(sqlquery, "SET synchronous_commit TO OFF)"); + res = PQexec(conn, sqlquery); + if (PQresultStatus(res) != PGRES_COMMAND_OK) + { + log_err("Can't set synchronous_commit: %s\n", PQerrorMessage(conn)); + PQclear(res); + PQfinish(conn); + exit(ERR_BAD_CONFIG); + } + /* * inform the master we will start a backup and get the first XLog filename * so we can say to the user we need those files