diff --git a/dbutils.c b/dbutils.c index 58e73170..5ced8ca3 100644 --- a/dbutils.c +++ b/dbutils.c @@ -804,3 +804,29 @@ stop_backup(PGconn *conn, char *last_wal_segment) return true; } + + +bool +set_config_bool(PGconn *conn, const char *config_param, bool state) +{ + char sqlquery[QUERY_STR_LEN]; + PGresult *res; + + sqlquery_snprintf(sqlquery, + "SET %s TO %s", + config_param, + state ? "TRUE" : "FALSE"); + + res = PQexec(conn, sqlquery); + + if (PQresultStatus(res) != PGRES_COMMAND_OK) + { + log_err("Unable to set '%s': %s\n", config_param, PQerrorMessage(conn)); + PQclear(res); + return false; + } + + PQclear(res); + + return true; +} diff --git a/dbutils.h b/dbutils.h index 49b9676e..e5d59f3a 100644 --- a/dbutils.h +++ b/dbutils.h @@ -57,5 +57,6 @@ bool create_replication_slot(PGconn *conn, char *slot_name); bool start_backup(PGconn *conn, char *first_wal_segment); bool stop_backup(PGconn *conn, char *last_wal_segment); +bool set_config_bool(PGconn *conn, const char *config_param, bool state); #endif diff --git a/repmgr.c b/repmgr.c index a8bf0998..5685cac8 100644 --- a/repmgr.c +++ b/repmgr.c @@ -1114,6 +1114,17 @@ do_standby_clone(void) if(runtime_options.rsync_only) { + + /* + * From pg 9.1 default is to wait for a sync standby to ack, avoid that by + * turning off sync rep for this session + */ + if(set_config_bool(primary_conn, "synchronous_commit", false) == false) + { + PQfinish(primary_conn); + exit(ERR_BAD_CONFIG); + } + if(start_backup(primary_conn, first_wal_segment) == false) { r = ERR_BAD_BASEBACKUP;