Add general check function "check_replication_slots_available()"

Make the code previously only used by "standby follow" generally
available - we'll want to use this from "node rejoin" as well.

While we're at it, when reporting failure due to lack of free
replication slots, report the current value of "max_replication_slots".
This commit is contained in:
Ian Barwick
2020-02-03 16:42:04 +09:00
parent ab9c84c655
commit cd7f36a6fd
6 changed files with 48 additions and 25 deletions

View File

@@ -2824,31 +2824,14 @@ do_standby_follow(void)
if (config_file_options.use_replication_slots)
{
int free_slots = get_free_replication_slot_count(follow_target_conn);
if (free_slots < 0)
bool slots_available = check_replication_slots_available(follow_target_node_id,
follow_target_conn);
if (slots_available == false)
{
log_error(_("unable to determine number of free replication slots on node %i"),
follow_target_node_id);
PQfinish(follow_target_conn);
PQfinish(local_conn);
exit(ERR_FOLLOW_FAIL);
}
if (free_slots == 0)
{
log_error(_("no free replication slots available on node %i"), follow_target_node_id);
log_hint(_("consider increasing \"max_replication_slots\""));
PQfinish(follow_target_conn);
PQfinish(local_conn);
exit(ERR_FOLLOW_FAIL);
}
else if (runtime_options.dry_run == true)
{
log_info(_("replication slots in use, %i free slots on node %i"),
follow_target_node_id,
free_slots);
}
}
/* XXX check this is not current upstream anyway */