Standardize "primary_conninfo" generation

Previously repmgr would write all the default libpq parameters
into "primary_conninfo" on "standby clone", but not for
"standby follow", which is inconsistent.

For repmgr4 we'll determine that the upstream node's conninfo
must be canonical and contain all required connection parameters,
even if these are available as defaults or environment variables
in the local environment, as those are transient and may not
be available in all environments/situations.

recovery.conf's "primary_conninfo" will be generated using the
upstream's conninfo parameters, except for those specific
to the downstream node. These are:

  - "application_name": this will always be set to the
      "node_name"  of the downstream node
  - "passfile" and "servicefile": these, must of course
    reference files on the downstream node so will be extracted
    from the downstream node's conninfo, if set
This commit is contained in:
Ian Barwick
2017-08-10 12:37:50 +09:00
parent 1cb0adfdcb
commit 7ca68b7cc8
4 changed files with 49 additions and 33 deletions

View File

@@ -111,7 +111,7 @@ main(int argc, char **argv)
* when the connection is made.
*/
initialize_conninfo_params(&source_conninfo, true);
initialize_conninfo_params(&source_conninfo, false);
for (c = 0; c < source_conninfo.size && source_conninfo.keywords[c]; c++)
{
@@ -2433,7 +2433,8 @@ copy_remote_files(char *host, char *remote_user, char *remote_path,
* Creates a recovery.conf file for a standby
*
* A database connection pointer is required for escaping primary_conninfo
* parameters. When cloning from Barman and --no-upstream-connection ) this might not be
* parameters. When cloning from Barman and --no-upstream-connection ) this
* might not be available.
*/
bool
create_recovery_file(t_node_info *node_record, t_conninfo_param_list *recovery_conninfo, const char *data_dir)
@@ -2572,12 +2573,15 @@ write_primary_conninfo(char *line, t_conninfo_param_list *param_list)
*/
if (strcmp(param_list->keywords[c], "dbname") == 0 ||
strcmp(param_list->keywords[c], "replication") == 0 ||
(runtime_options.use_recovery_conninfo_password == false &&
strcmp(param_list->keywords[c], "password") == 0) ||
(param_list->values[c] == NULL) ||
(param_list->values[c] != NULL && param_list->values[c][0] == '\0'))
continue;
/* only include "password" if explicitly requested */
if (runtime_options.use_recovery_conninfo_password == false &&
strcmp(param_list->keywords[c], "password") == 0)
continue;
if (conninfo_buf.len != 0)
appendPQExpBufferChar(&conninfo_buf, ' ');