Port number to be recovered (<productname>Pgpool-II</productname> 4.1 or after)
</para>
</listitem>
+ <listitem>
+ <para>
+ Hostname of the main (primary) node
+ (<productname>Pgpool-II</productname> 4.3 or after). Before
+ the hostname of the main (primary) node was obtained by
+ using <command>hostname</command> command. This is mostly ok
+ since the script runs on the main (primary) node
+ anyway. However in some systems the hostname obtained
+ by <command>hostname</command> command is different from the
+ hostname defined in backend_hostname configuration parameter.
+ This could cause a trouble
+ in <xref linkend="guc-detach-false-primary"> because it checks
+ connectivity between primary and standby node by
+ using <literal>host</literal> parameter
+ in <varname>primary_conninfo</varname> parameter, which is
+ generated
+ by <varname>recovery_1st_stage_command</varname>. Thus it is
+ strongly recommended to use this parameter instead of
+ using <command>hostname</command> command to obtain the
+ hostname of the primary node
+ in <varname>recovery_1st_stage_command</varname>.
+ </para>
+ </listitem>
</itemizedlist>
<note>
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2020 PgPool Global Development Group
+ * Copyright (c) 2003-2021 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
/*
* Call pgpool_recovery() function.
+ *
+ * "main_backend" is either primary backend node (in streaming replication
+ * mode) or main backend node (in other mode).
*/
static void
exec_recovery(PGconn *conn, BackendInfo * main_backend, BackendInfo * recovery_backend, char stage, int recovery_node)
PGresult *result;
char *hostname;
char *script;
+ char *main_hostname;
if (strlen(recovery_backend->backend_hostname) == 0 || *(recovery_backend->backend_hostname) == '/')
hostname = "localhost";
else
hostname = recovery_backend->backend_hostname;
+ if (strlen(main_backend->backend_hostname) == 0 || *(main_backend->backend_hostname) == '/')
+ main_hostname = "localhost";
+ else
+ main_hostname = main_backend->backend_hostname;
+
script = (stage == FIRST_STAGE) ?
pool_config->recovery_1st_stage_command : pool_config->recovery_2nd_stage_command;
*/
snprintf(recovery_command,
sizeof(recovery_command),
- "SELECT pgpool_recovery('%s', '%s', '%s', '%d', %d, '%d')",
+ "SELECT pgpool_recovery('%s', '%s', '%s', '%d', %d, '%d', '%s')",
script,
hostname,
recovery_backend->backend_data_directory,
main_backend->backend_port,
recovery_node,
- recovery_backend->backend_port
+ recovery_backend->backend_port,
+ main_hostname
);
ereport(LOG,
DATA = uninstall_pgpool-recovery.sql
EXTENSION = pgpool_recovery
-DATA = pgpool_recovery--1.1.sql pgpool_recovery--1.2.sql pgpool_recovery--1.1--1.2.sql pgpool_recovery--1.3.sql pgpool_recovery--1.2--1.3.sql
+DATA = pgpool_recovery--1.1.sql pgpool_recovery--1.2.sql pgpool_recovery--1.1--1.2.sql \
+ pgpool_recovery--1.3.sql pgpool_recovery--1.2--1.3.sql \
+ pgpool_recovery--1.4.sql pgpool_recovery--1.3--1.4.sql
# if you are using PostgreSQL 8.0 or later,
# using pg_config is recommended.
elog(ERROR, "must be superuser to use pgpool_recovery function");
#endif
- if (PG_NARGS() >= 6) /* Pgpool-II 4.1 or later */
+ if (PG_NARGS() >= 7) /* Pgpool-II 4.3 or later */
+ {
+ char *primary_port = DatumGetCString(DirectFunctionCall1(textout,
+ PointerGetDatum(PG_GETARG_TEXT_P(3))));
+ int remote_node = PG_GETARG_INT32(4);
+
+ char *remote_port = DatumGetCString(DirectFunctionCall1(textout,
+ PointerGetDatum(PG_GETARG_TEXT_P(5))));
+
+ char *primary_host = DatumGetCString(DirectFunctionCall1(textout,
+ PointerGetDatum(PG_GETARG_TEXT_P(6))));
+
+ snprintf(recovery_script, sizeof(recovery_script), "\"%s/%s\" \"%s\" \"%s\" \"%s\" \"%s\" %d \"%s\" \"%s\"",
+ DataDir, script, DataDir, remote_host,
+ remote_data_directory, primary_port, remote_node, remote_port, primary_host);
+ }
+ if (PG_NARGS() >= 6) /* Pgpool-II 4.1 or 4.2 */
{
char *primary_port = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(PG_GETARG_TEXT_P(3))));
+CREATE FUNCTION pgpool_recovery(IN script_name text,
+ IN remote_host text,
+ IN remote_data_directory text,
+ IN primary_port text,
+ IN remote_node integer,
+ IN remote_port text)
+ IN primary_host text,
+RETURNS bool
+AS 'MODULE_PATHNAME', 'pgpool_recovery'
+LANGUAGE C STRICT;
+
CREATE FUNCTION pgpool_recovery(IN script_name text,
IN remote_host text,
IN remote_data_directory text,
# pgpool-recovery extension
-comment = 'recovery functions for pgpool-II for V4.1 or later'
-default_version = '1.3'
+comment = 'recovery functions for pgpool-II for V4.3'
+default_version = '1.4'
module_pathname = '$libdir/pgpool-recovery'
relocatable = true