Use "immediately_reserve" parameter in pg_create_physical_replication_slot (9.6)

This commit is contained in:
Ian Barwick
2016-04-04 12:56:00 +09:00
committed by Ian Barwick
parent 683c54325e
commit b88d27248c
3 changed files with 20 additions and 7 deletions

View File

@@ -889,7 +889,7 @@ get_repmgr_schema_quoted(PGconn *conn)
bool
create_replication_slot(PGconn *conn, char *slot_name)
create_replication_slot(PGconn *conn, char *slot_name, int server_version_num)
{
char sqlquery[QUERY_STR_LEN];
int query_res;
@@ -926,9 +926,19 @@ create_replication_slot(PGconn *conn, char *slot_name)
return false;
}
sqlquery_snprintf(sqlquery,
"SELECT * FROM pg_create_physical_replication_slot('%s')",
slot_name);
/* In 9.6 and later, reserve the LSN straight away */
if (server_version_num >= 90600)
{
sqlquery_snprintf(sqlquery,
"SELECT * FROM pg_create_physical_replication_slot('%s', TRUE)",
slot_name);
}
else
{
sqlquery_snprintf(sqlquery,
"SELECT * FROM pg_create_physical_replication_slot('%s')",
slot_name);
}
log_debug(_("create_replication_slot(): Creating slot '%s' on primary\n"), slot_name);
log_verbose(LOG_DEBUG, "create_replication_slot():\n%s\n", sqlquery);

View File

@@ -115,7 +115,7 @@ int wait_connection_availability(PGconn *conn, long long timeout);
bool cancel_query(PGconn *conn, int timeout);
char *get_repmgr_schema(void);
char *get_repmgr_schema_quoted(PGconn *conn);
bool create_replication_slot(PGconn *conn, char *slot_name);
bool create_replication_slot(PGconn *conn, char *slot_name, int server_version_num);
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);
@@ -133,3 +133,4 @@ int get_node_replication_state(PGconn *conn, char *node_name, char *output)
t_server_type parse_node_type(const char *type);
int get_data_checksum_version(const char *data_directory);
#endif

View File

@@ -1589,7 +1589,7 @@ do_standby_clone(void)
*/
if (options.use_replication_slots)
{
if (create_replication_slot(upstream_conn, repmgr_slot_name) == false)
if (create_replication_slot(upstream_conn, repmgr_slot_name, server_version_num) == false)
{
PQfinish(upstream_conn);
exit(ERR_DB_QUERY);
@@ -2550,7 +2550,9 @@ do_standby_follow(void)
if (options.use_replication_slots)
{
if (create_replication_slot(master_conn, repmgr_slot_name) == false)
int server_version_num = get_server_version(master_conn, NULL);
if (create_replication_slot(master_conn, repmgr_slot_name, server_version_num) == false)
{
PQExpBufferData event_details;
initPQExpBuffer(&event_details);