pgpool2.git / summary / log / commit / refs
commit 93fcdbc1fe6fc4cf004657c9c4b52feeb977efa9
Author: Bo Peng <pengbo@sraoss.co.jp>
Date: Mon Jun 13 11:48:46 2022 +0000
Rename configuration parameter delegate_IP to delegate_ip.
For compatibility with the old versions, the old paramter delegate_IP can still work.
If the old paramter delegate_IP is used, Pgpool-II will set the value to
delegate_ip and throw a warning message.
This commit also fixes segfault of fail_over_on_backend_error
and changes the behavior to set the value to failover_on_backend_error
if fail_over_on_backend_error is used.
doc.ja/src/sgml/example-AWS.sgml | 2 +-
doc.ja/src/sgml/example-cluster.sgml | 4 ++--
doc.ja/src/sgml/watchdog.sgml | 20 +++++++++----------
doc/src/sgml/example-AWS.sgml | 2 +-
doc/src/sgml/example-cluster.sgml | 4 ++--
doc/src/sgml/watchdog.sgml | 12 ++++++------
src/config/pool_config_variables.c | 37 +++++++++++++++++++++++++++++++-----
src/include/pool_config.h | 2 +-
src/sample/pgpool.conf.sample-stream | 2 +-
src/utils/pool_process_reporting.c | 4 ++--
src/watchdog/watchdog.c | 2 +-
src/watchdog/wd_escalation.c | 4 ++--
src/watchdog/wd_if.c | 14 +++++++-------
src/watchdog/wd_utils.c | 2 +-
14 files changed, 69 insertions(+), 42 deletions(-)
diff --git a/doc.ja/src/sgml/example-AWS.sgml b/doc.ja/src/sgml/example-AWS.sgml
index b571be755..bc5e689e0 100644
--- a/doc.ja/src/sgml/example-AWS.sgml
+++ b/doc.ja/src/sgml/example-AWS.sgml
@@ -103,7 +103,7 @@
<programlisting>
use_watchdog = on
-delegate_IP = ''
+delegate_ip = ''
...
wd_escalation_command = '$path_to_script/aws-escalation.sh'
wd_de_escalation_command = '$path_to_script/aws-de-escalation.sh'
diff --git a/doc.ja/src/sgml/example-cluster.sgml b/doc.ja/src/sgml/example-cluster.sgml
index 80100fcd8..a20dab6ab 100644
--- a/doc.ja/src/sgml/example-cluster.sgml
+++ b/doc.ja/src/sgml/example-cluster.sgml
@@ -915,11 +915,11 @@ postgres:AESHs/pWL5rtXy2IwuzroHfqg==
use_watchdog = on
</programlisting>
<para>
- アクティブ機が立ち上げる仮想IPを<varname>delegate_IP</varname>に指定します。
+ アクティブ機が立ち上げる仮想IPを<varname>delegate_ip</varname>に指定します。
仮想IPはまだ使われていないIPアドレスを指定してください。
</para>
<programlisting>
-delegate_IP = '192.168.137.150'
+delegate_ip = '192.168.137.150'
</programlisting>
<para>
diff --git a/doc.ja/src/sgml/watchdog.sgml b/doc.ja/src/sgml/watchdog.sgml
index 89bf87974..f212d105a 100644
--- a/doc.ja/src/sgml/watchdog.sgml
+++ b/doc.ja/src/sgml/watchdog.sgml
@@ -365,13 +365,13 @@
<variablelist>
- <varlistentry id="guc-delegate-IP" xreflabel="delegate_IP">
- <term><varname>delegate_IP</varname> (<type>string</type>)
+ <varlistentry id="guc-delegate-ip" xreflabel="delegate_ip">
+ <term><varname>delegate_ip</varname> (<type>string</type>)
<indexterm>
<!--
- <primary><varname>delegate_IP</varname> configuration parameter</primary>
+ <primary><varname>delegate_ip</varname> configuration parameter</primary>
-->
- <primary><varname>delegate_IP</varname>設定パラメータ</primary>
+ <primary><varname>delegate_ip</varname>設定パラメータ</primary>
</indexterm>
</term>
<listitem>
@@ -453,7 +453,7 @@
to run <command>sudo</command> command without a password, and specify it such as
<literal>"/usr/bin/sudo /sbin/ip addr add $_IP_$/24 dev eth0 label eth0:0"</literal>.
<literal>$_IP_$</literal> will get replaced by the IP address
- specified in the <xref linkend="guc-delegate-IP">.
+ specified in the <xref linkend="guc-delegate-ip">.
-->
仮想IPを起動するために実行するコマンドを指定します。
<command>"ip addr add $_IP_$/24 dev eth0 label eth0:0"</command>のようにコマンドとパラメータを指定します。
@@ -461,7 +461,7 @@
<command>ip</command>コマンドに<command>setuid</command>を設定するか、
<productname>Pgpool-II</productname>起動ユーザ(デフォルトでは<literal>postgres</literal>)がパスワードなしに<command>sudo</command>を実行できるように設定し、
<command>sudo</command>を介したコマンドを<literal>"/usr/bin/sudo /sbin/ip addr add $_IP_$/24 dev eth0 label eth0:0"</literal>のように指定します。
- <literal>$_IP_$</literal>は<xref linkend="guc-delegate-IP">で指定されたIPアドレスに置換されます。
+ <literal>$_IP_$</literal>は<xref linkend="guc-delegate-ip">で指定されたIPアドレスに置換されます。
</para>
<para>
このパラメータは、サーバ起動時にのみ設定できます。
@@ -490,7 +490,7 @@
to run <command>sudo</command> command without a password, and specify it such as
<literal>"/usr/bin/sudo /sbin/ip addr del $_IP_$/24 dev eth0"</literal>.
<literal>$_IP_$</literal> will get replaced by the IP address
- specified in the <xref linkend="guc-delegate-IP">.
+ specified in the <xref linkend="guc-delegate-ip">.
-->
仮想IPを停止するために実行するコマンドを指定します。
<literal>"ip addr del $_IP_$/24 dev eth0"</literal>のようにコマンドとパラメータを指定します。
@@ -498,7 +498,7 @@
<command>ip</command>コマンドに<command>setuid</command>を設定するか、
<productname>Pgpool-II</productname>起動ユーザ(デフォルトでは<literal>postgres</literal>)がパスワードなしに<command>sudo</command>を実行できるように設定し、
<command>sudo</command>を介したコマンドを<literal>"/usr/bin/sudo /sbin/ip addr del $_IP_$/24 dev eth0"</literal>のように指定します。
- <literal>$_IP_$</literal>は<xref linkend="guc-delegate-IP">で指定されたIPアドレスに置換されます。
+ <literal>$_IP_$</literal>は<xref linkend="guc-delegate-ip">で指定されたIPアドレスに置換されます。
</para>
<para>
<!--
@@ -564,7 +564,7 @@
to run <command>sudo</command> command without a password, and specify it such as
<literal>"/usr/bin/sudo /usr/sbin/arping -U $_IP_$ -w 1 -I eth0"</literal>.
<literal>$_IP_$</literal> will get replaced by
- the IP address specified in the <varname>delegate_IP</varname>.
+ the IP address specified in the <varname>delegate_ip</varname>.
-->
IPアドレス切り替え後にARPリクエストを送信するコマンドです。
<literal>"arping -U $_IP_$ -w 1 -I eth0"</literal>のようにコマンドとパラメータを指定します。
@@ -572,7 +572,7 @@
<command>arping</command>コマンドに<literal>setuid</literal>を設定するか、
<productname>Pgpool-II</productname>起動ユーザ(デフォルトでは<literal>postgres</literal>ユーザ)がパスワードなしに<command>sudo</command>を実行できるように設定し、
<command>sudo</command>を介したコマンドを<literal>"/usr/bin/sudo /usr/sbin/arping -U $_IP_$ -w 1 -I eth0"</literal>のように設定します。
- <literal>$_IP_$</literal>は<xref linkend="guc-delegate-IP">で指定されたIPアドレスに置換されます。
+ <literal>$_IP_$</literal>は<xref linkend="guc-delegate-ip">で指定されたIPアドレスに置換されます。
</para>
<para>
<!--
diff --git a/doc/src/sgml/example-AWS.sgml b/doc/src/sgml/example-AWS.sgml
index 111e420fc..0b33306fe 100644
--- a/doc/src/sgml/example-AWS.sgml
+++ b/doc/src/sgml/example-AWS.sgml
@@ -71,7 +71,7 @@
</para>
<programlisting>
use_watchdog = on
-delegate_IP = ''
+delegate_ip = ''
...
wd_escalation_command = '$path_to_script/aws-escalation.sh'
wd_de_escalation_command = '$path_to_script/aws-de-escalation.sh'
diff --git a/doc/src/sgml/example-cluster.sgml b/doc/src/sgml/example-cluster.sgml
index a6bf26af0..8f894afd4 100644
--- a/doc/src/sgml/example-cluster.sgml
+++ b/doc/src/sgml/example-cluster.sgml
@@ -884,7 +884,7 @@ use_watchdog = on
Ensure that the IP address set to virtual IP isn't used yet.
</para>
<programlisting>
-delegate_IP = '192.168.137.150'
+delegate_ip = '192.168.137.150'
</programlisting>
<para>
@@ -1020,7 +1020,7 @@ wd_escalation_command = '/etc/pgpool-II/escalation.sh'
<para>
Basically, it should work if you change the following variables according to your environment.
PGPOOL is tha array of the hostname that running Pgpool-II.
- VIP is the virtual IP address that you set as delegate_IP.
+ VIP is the virtual IP address that you set as delegate_ip.
DEVICE is the network interface for the virtual IP.
</para>
<programlisting>
diff --git a/doc/src/sgml/watchdog.sgml b/doc/src/sgml/watchdog.sgml
index c09f3bf20..e8d5f6d7f 100644
--- a/doc/src/sgml/watchdog.sgml
+++ b/doc/src/sgml/watchdog.sgml
@@ -257,10 +257,10 @@ pgpool_port2 = 9999
<variablelist>
- <varlistentry id="guc-delegate-IP" xreflabel="delegate_IP">
- <term><varname>delegate_IP</varname> (<type>string</type>)
+ <varlistentry id="guc-delegate-ip" xreflabel="delegate_ip">
+ <term><varname>delegate_ip</varname> (<type>string</type>)
<indexterm>
- <primary><varname>delegate_IP</varname> configuration parameter</primary>
+ <primary><varname>delegate_ip</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
@@ -318,7 +318,7 @@ pgpool_port2 = 9999
to run <command>sudo</command> command without a password, and specify it such as
<literal>"/usr/bin/sudo /sbin/ip addr add $_IP_$/24 dev eth0 label eth0:0"</literal>.
<literal>$_IP_$</literal> will get replaced by the IP address
- specified in the <xref linkend="guc-delegate-IP">.
+ specified in the <xref linkend="guc-delegate-ip">.
</para>
<para>
This parameter can only be set at server start.
@@ -343,7 +343,7 @@ pgpool_port2 = 9999
to run <command>sudo</command> command without a password, and specify it such as
<literal>"/usr/bin/sudo /sbin/ip addr del $_IP_$/24 dev eth0"</literal>.
<literal>$_IP_$</literal> will get replaced by the IP address
- specified in the <xref linkend="guc-delegate-IP">.
+ specified in the <xref linkend="guc-delegate-ip">.
</para>
<para>
This parameter can only be set at server start.
@@ -390,7 +390,7 @@ pgpool_port2 = 9999
to run <command>sudo</command> command without a password, and specify it such as
<literal>"/usr/bin/sudo /usr/sbin/arping -U $_IP_$ -w 1 -I eth0"</literal>.
<literal>$_IP_$</literal> will get replaced by
- the IP address specified in the <varname>delegate_IP</varname>.
+ the IP address specified in the <varname>delegate_ip</varname>.
</para>
<para>
This parameter can only be set at server start.
diff --git a/src/config/pool_config_variables.c b/src/config/pool_config_variables.c
index a138e382e..90446bd79 100644
--- a/src/config/pool_config_variables.c
+++ b/src/config/pool_config_variables.c
@@ -137,6 +137,7 @@ static bool BackendSlotEmptyCheckFunc(int index);
/*variable custom assign functions */
static bool FailOverOnBackendErrorAssignMessage(ConfigContext scontext, bool newval, int elevel);
+static bool DelegateIPAssignMessage(ConfigContext scontext, char *newval, int elevel);
static bool BackendPortAssignFunc(ConfigContext context, int newval, int index, int elevel);
static bool BackendHostAssignFunc(ConfigContext context, char *newval, int index, int elevel);
static bool BackendDataDirAssignFunc(ConfigContext context, char *newval, int index, int elevel);
@@ -1039,10 +1040,20 @@ static struct config_string ConfigureNamesString[] =
{
{"delegate_IP", CFGCXT_INIT, WATCHDOG_CONFIG,
+ "Old config parameter for delegate_ip.",
+ CONFIG_VAR_TYPE_STRING, false, VAR_HIDDEN_IN_SHOW_ALL
+ },
+ NULL,
+ "",
+ DelegateIPAssignMessage, NULL, NULL, NULL
+ },
+
+ {
+ {"delegate_ip", CFGCXT_INIT, WATCHDOG_CONFIG,
"Delegate IP address to be used when pgpool node become a watchdog cluster leader.",
CONFIG_VAR_TYPE_STRING, false, 0
},
- &g_pool_config.delegate_IP,
+ &g_pool_config.delegate_ip,
"",
NULL, NULL, NULL, NULL
},
@@ -4606,8 +4617,22 @@ FailOverOnBackendErrorAssignMessage(ConfigContext scontext, bool newval, int ele
if (scontext != CFGCXT_BOOT)
ereport(WARNING,
(errmsg("fail_over_on_backend_error is changed to failover_on_backend_error"),
- errdetail("setting failover_on_backend_error has no effect"),
- errhint("use failover_on_backend_error instead")));
+ errdetail("if fail_over_on_backend_error is specified, the value will be set to failover_on_backend_error")));
+ g_pool_config.failover_on_backend_error = newval;
+ return true;
+}
+/*
+ * Throws warning for if someone uses the removed delegate_IP
+ * configuration parameter and set the value to delegate_ip
+ */
+static bool
+DelegateIPAssignMessage(ConfigContext scontext, char *newval, int elevel)
+{
+ if (scontext != CFGCXT_BOOT)
+ ereport(WARNING,
+ (errmsg("delegate_IP is changed to delegate_ip"),
+ errdetail("if delegate_IP is specified, the value will be set to delegate_ip")));
+ g_pool_config.delegate_ip = newval;
return true;
}
/*
@@ -5404,8 +5429,10 @@ ShowOption(struct config_generic *record, int index, int elevel)
if (conf->show_hook)
val = (*conf->show_hook) ();
- else
+ else if (conf->variable)
val = *conf->variable ? "on" : "off";
+ else
+ val = "";
}
break;
@@ -5485,7 +5512,7 @@ ShowOption(struct config_generic *record, int index, int elevel)
if (conf->show_hook)
val = (*conf->show_hook) ();
- else if (*conf->variable && **conf->variable)
+ else if (conf->variable && *conf->variable && **conf->variable)
val = *conf->variable;
else
val = "";
diff --git a/src/include/pool_config.h b/src/include/pool_config.h
index 32f841b6f..13b3aa3d7 100644
--- a/src/include/pool_config.h
+++ b/src/include/pool_config.h
@@ -576,7 +576,7 @@ typedef struct
int pgpool_node_id; /* pgpool (watchdog) node id */
WdNodesConfig wd_nodes; /* watchdog lists */
char *trusted_servers; /* icmp reachable server list (A,B,C) */
- char *delegate_IP; /* delegate IP address */
+ char *delegate_ip; /* delegate IP address */
int wd_interval; /* lifecheck interval (sec) */
char *wd_authkey; /* Authentication key for watchdog
* communication */
diff --git a/src/sample/pgpool.conf.sample-stream b/src/sample/pgpool.conf.sample-stream
index 248f46516..312014a4c 100644
--- a/src/sample/pgpool.conf.sample-stream
+++ b/src/sample/pgpool.conf.sample-stream
@@ -690,7 +690,7 @@ hostname0 = ''
# - Virtual IP control Setting -
-#delegate_IP = ''
+#delegate_ip = ''
# delegate IP address
# If this is empty, virtual IP never bring up.
# (change requires restart)
diff --git a/src/utils/pool_process_reporting.c b/src/utils/pool_process_reporting.c
index 5f2e40c30..2f9157a44 100644
--- a/src/utils/pool_process_reporting.c
+++ b/src/utils/pool_process_reporting.c
@@ -803,8 +803,8 @@ get_config(int *nrows)
StrNCpy(status[i].desc, "upper server list to observe connection", POOLCONFIG_MAXDESCLEN);
i++;
- StrNCpy(status[i].name, "delegate_IP", POOLCONFIG_MAXNAMELEN);
- snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->delegate_IP);
+ StrNCpy(status[i].name, "delegate_ip", POOLCONFIG_MAXNAMELEN);
+ snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->delegate_ip);
StrNCpy(status[i].desc, "delegate IP address of leader pgpool", POOLCONFIG_MAXDESCLEN);
i++;
diff --git a/src/watchdog/watchdog.c b/src/watchdog/watchdog.c
index 95d3da1c0..d7001df7d 100644
--- a/src/watchdog/watchdog.c
+++ b/src/watchdog/watchdog.c
@@ -755,7 +755,7 @@ wd_cluster_initialize(void)
gettimeofday(&g_cluster.localNode->startup_time, NULL);
strncpy(g_cluster.localNode->hostname, pool_config->wd_nodes.wd_node_info[pgpool_node_id].hostname, sizeof(g_cluster.localNode->hostname) - 1);
- strncpy(g_cluster.localNode->delegate_ip, pool_config->delegate_IP, sizeof(g_cluster.localNode->delegate_ip) - 1);
+ strncpy(g_cluster.localNode->delegate_ip, pool_config->delegate_ip, sizeof(g_cluster.localNode->delegate_ip) - 1);
/* Assign the node name */
{
struct utsname unameData;
diff --git a/src/watchdog/wd_escalation.c b/src/watchdog/wd_escalation.c
index 9acd4e49e..b0d01ecb6 100644
--- a/src/watchdog/wd_escalation.c
+++ b/src/watchdog/wd_escalation.c
@@ -134,7 +134,7 @@ fork_escalation_process(void)
/*
* STEP 3 bring up the delegate IP
*/
- if (strlen(pool_config->delegate_IP) != 0)
+ if (strlen(pool_config->delegate_ip) != 0)
{
if (wd_IP_up() != WD_OK)
ereport(WARNING,
@@ -211,7 +211,7 @@ fork_plunging_process(void)
* STEP 2 bring down the delegate IP
*/
- if (strlen(pool_config->delegate_IP) != 0)
+ if (strlen(pool_config->delegate_ip) != 0)
{
if (wd_IP_down() != WD_OK)
ereport(WARNING,
diff --git a/src/watchdog/wd_if.c b/src/watchdog/wd_if.c
index 1de2337e2..f206ec9b3 100644
--- a/src/watchdog/wd_if.c
+++ b/src/watchdog/wd_if.c
@@ -108,7 +108,7 @@ wd_IP_up(void)
char *command;
int i;
- if (strlen(pool_config->delegate_IP) == 0)
+ if (strlen(pool_config->delegate_ip) == 0)
{
ereport(LOG,
(errmsg("trying to acquire the delegate IP address, but delegate IP is not configured")));
@@ -163,7 +163,7 @@ wd_IP_up(void)
{
for (i = 0; i < WD_TRY_PING_AT_IPUP; i++)
{
- if (wd_is_ip_exists(pool_config->delegate_IP) == true)
+ if (wd_is_ip_exists(pool_config->delegate_ip) == true)
break;
ereport(LOG,
(errmsg("waiting for the delegate IP address to become active"),
@@ -176,7 +176,7 @@ wd_IP_up(void)
if (rtn == WD_OK)
ereport(LOG,
- (errmsg("successfully acquired the delegate IP:\"%s\"", pool_config->delegate_IP),
+ (errmsg("successfully acquired the delegate IP:\"%s\"", pool_config->delegate_ip),
errdetail("'if_up_cmd' returned with success")));
else
ereport(LOG,
@@ -192,7 +192,7 @@ wd_IP_down(void)
char path[WD_MAX_PATH_LEN];
char *command;
- if (strlen(pool_config->delegate_IP) == 0)
+ if (strlen(pool_config->delegate_ip) == 0)
{
ereport(LOG,
(errmsg("trying to release the delegate IP address, but delegate IP is not configured")));
@@ -222,13 +222,13 @@ wd_IP_down(void)
if (rtn == WD_OK)
{
ereport(LOG,
- (errmsg("successfully released the delegate IP:\"%s\"", pool_config->delegate_IP),
+ (errmsg("successfully released the delegate IP:\"%s\"", pool_config->delegate_ip),
errdetail("'if_down_cmd' returned with success")));
}
else
{
ereport(LOG,
- (errmsg("failed to release the delegate IP:\"%s\"", pool_config->delegate_IP),
+ (errmsg("failed to release the delegate IP:\"%s\"", pool_config->delegate_ip),
errdetail("'if_down_cmd' failed")));
}
return rtn;
@@ -272,7 +272,7 @@ exec_if_cmd(char *path, char *command)
return WD_NG;
}
- buf = string_replace(command, "$_IP_$", pool_config->delegate_IP);
+ buf = string_replace(command, "$_IP_$", pool_config->delegate_ip);
bp = buf;
while (*bp == ' ')
diff --git a/src/watchdog/wd_utils.c b/src/watchdog/wd_utils.c
index d9d8c7153..a00f541b2 100644
--- a/src/watchdog/wd_utils.c
+++ b/src/watchdog/wd_utils.c
@@ -67,7 +67,7 @@ wd_check_network_command_configurations(void)
* If delegate IP is not assigned to the node the configuration is not
* used
*/
- if (strlen(pool_config->delegate_IP) == 0)
+ if (strlen(pool_config->delegate_ip) == 0)
return;
/* check setuid bit of ifup command */
[parent: 58ad98ca5cc4]