mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
repmgr: support further renamed WAL function for PostreSQL 10
pg_xlogfile_name() -> pg_walfile_name()
This commit is contained in:
31
dbutils.c
31
dbutils.c
@@ -1132,15 +1132,25 @@ drop_replication_slot(PGconn *conn, char *slot_name)
|
||||
|
||||
|
||||
bool
|
||||
start_backup(PGconn *conn, char *first_wal_segment, bool fast_checkpoint)
|
||||
start_backup(PGconn *conn, char *first_wal_segment, bool fast_checkpoint, int server_version_num)
|
||||
{
|
||||
char sqlquery[QUERY_STR_LEN];
|
||||
PGresult *res;
|
||||
|
||||
sqlquery_snprintf(sqlquery,
|
||||
"SELECT pg_catalog.pg_xlogfile_name(pg_catalog.pg_start_backup('repmgr_standby_clone_%ld', %s))",
|
||||
time(NULL),
|
||||
fast_checkpoint ? "TRUE" : "FALSE");
|
||||
if (server_version_num >= 100000)
|
||||
{
|
||||
sqlquery_snprintf(sqlquery,
|
||||
"SELECT pg_catalog.pg_walfile_name(pg_catalog.pg_start_backup('repmgr_standby_clone_%ld', %s))",
|
||||
time(NULL),
|
||||
fast_checkpoint ? "TRUE" : "FALSE");
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlquery_snprintf(sqlquery,
|
||||
"SELECT pg_catalog.pg_xlogfile_name(pg_catalog.pg_start_backup('repmgr_standby_clone_%ld', %s))",
|
||||
time(NULL),
|
||||
fast_checkpoint ? "TRUE" : "FALSE");
|
||||
}
|
||||
|
||||
log_verbose(LOG_DEBUG, "start_backup():\n%s\n", sqlquery);
|
||||
|
||||
@@ -1168,12 +1178,19 @@ start_backup(PGconn *conn, char *first_wal_segment, bool fast_checkpoint)
|
||||
|
||||
|
||||
bool
|
||||
stop_backup(PGconn *conn, char *last_wal_segment)
|
||||
stop_backup(PGconn *conn, char *last_wal_segment, int server_version_num)
|
||||
{
|
||||
char sqlquery[QUERY_STR_LEN];
|
||||
PGresult *res;
|
||||
|
||||
sqlquery_snprintf(sqlquery, "SELECT pg_catalog.pg_xlogfile_name(pg_catalog.pg_stop_backup())");
|
||||
if (server_version_num >= 100000)
|
||||
{
|
||||
sqlquery_snprintf(sqlquery, "SELECT pg_catalog.pg_walfile_name(pg_catalog.pg_stop_backup())");
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlquery_snprintf(sqlquery, "SELECT pg_catalog.pg_xlogfile_name(pg_catalog.pg_stop_backup())");
|
||||
}
|
||||
|
||||
res = PQexec(conn, sqlquery);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
|
||||
@@ -122,8 +122,8 @@ char *get_repmgr_schema_quoted(PGconn *conn);
|
||||
bool create_replication_slot(PGconn *conn, char *slot_name, int server_version_num, PQExpBufferData *error_msg);
|
||||
int get_slot_record(PGconn *conn, char *slot_name, t_replication_slot *record);
|
||||
bool drop_replication_slot(PGconn *conn, char *slot_name);
|
||||
bool start_backup(PGconn *conn, char *first_wal_segment, bool fast_checkpoint);
|
||||
bool stop_backup(PGconn *conn, char *last_wal_segment);
|
||||
bool start_backup(PGconn *conn, char *first_wal_segment, bool fast_checkpoint, int server_version_num);
|
||||
bool stop_backup(PGconn *conn, char *last_wal_segment, int server_version_num);
|
||||
bool set_config(PGconn *conn, const char *config_param, const char *config_value);
|
||||
bool set_config_bool(PGconn *conn, const char *config_param, bool state);
|
||||
bool witness_copy_node_records(PGconn *masterconn, PGconn *witnessconn, char *cluster_name);
|
||||
|
||||
15
repmgr.c
15
repmgr.c
@@ -3643,7 +3643,18 @@ do_standby_clone(void)
|
||||
initPQExpBuffer(&tablespace_map);
|
||||
}
|
||||
|
||||
if (start_backup(source_conn, first_wal_segment, runtime_options.fast_checkpoint) == false)
|
||||
/*
|
||||
* From 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(source_conn, "synchronous_commit", false) == false)
|
||||
{
|
||||
r = ERR_BAD_CONFIG;
|
||||
retval = ERR_BAD_CONFIG;
|
||||
goto stop_backup;
|
||||
}
|
||||
|
||||
if (start_backup(source_conn, first_wal_segment, runtime_options.fast_checkpoint, server_version_num) == false)
|
||||
{
|
||||
r = ERR_BAD_BASEBACKUP;
|
||||
retval = ERR_BAD_BASEBACKUP;
|
||||
@@ -3989,7 +4000,7 @@ stop_backup:
|
||||
if (mode == rsync && pg_start_backup_executed)
|
||||
{
|
||||
log_notice(_("notifying master about backup completion...\n"));
|
||||
if (stop_backup(source_conn, last_wal_segment) == false)
|
||||
if (stop_backup(source_conn, last_wal_segment, server_version_num) == false)
|
||||
{
|
||||
r = ERR_BAD_BASEBACKUP;
|
||||
retval = ERR_BAD_BASEBACKUP;
|
||||
|
||||
Reference in New Issue
Block a user