diff --git a/doc/repmgr-node-service.xml b/doc/repmgr-node-service.xml index a4eec443..1a5618f2 100644 --- a/doc/repmgr-node-service.xml +++ b/doc/repmgr-node-service.xml @@ -75,8 +75,22 @@ Issue a CHECKPOINT before stopping or restarting the node. + + Note that a superuser connection is required to be able to execute the + CHECKPOINT command. + + + + / + + + Connect as the named superuser instead of the normal &repmgr; user. + + + + diff --git a/repmgr-action-node.c b/repmgr-action-node.c index a374b62f..17b6e2f8 100644 --- a/repmgr-action-node.c +++ b/repmgr-action-node.c @@ -2028,10 +2028,44 @@ do_node_service(void) { PGconn *conn = NULL; - if (strlen(config_file_options.conninfo)) - conn = establish_db_connection(config_file_options.conninfo, true); + if (config_file_options.conninfo[0] != '\0') + { + t_conninfo_param_list node_conninfo = T_CONNINFO_PARAM_LIST_INITIALIZER; + char *errmsg = NULL; + bool parse_success = false; + + initialize_conninfo_params(&node_conninfo, false); + + parse_success = parse_conninfo_string(config_file_options.conninfo, + &node_conninfo, + &errmsg, false); + + if (parse_success == false) + { + log_error(_("unable to parse conninfo string \"%s\" for local node"), + config_file_options.conninfo); + log_detail("%s", errmsg); + + exit(ERR_BAD_CONFIG); + } + + /* + * If --superuser option provided, attempt to connect as the specified user + */ + + if (runtime_options.superuser[0] != '\0') + { + param_set(&node_conninfo, + "user", + runtime_options.superuser); + } + + conn = establish_db_connection_by_params(&node_conninfo, true); + } else + { conn = establish_db_connection_by_params(&source_conninfo, true); + } if (is_superuser_connection(conn, NULL) == false) { diff --git a/repmgr-client.c b/repmgr-client.c index 1814814d..d055e5ef 100644 --- a/repmgr-client.c +++ b/repmgr-client.c @@ -1692,6 +1692,7 @@ check_cli_parameters(const int action) { case STANDBY_CLONE: case NODE_CHECK: + case NODE_SERVICE: break; default: item_list_append_format(&cli_warnings,