Rename configuration parameter delegate_IP to delegate_ip.
authorBo Peng <pengbo@sraoss.co.jp>
Mon, 13 Jun 2022 11:48:46 +0000 (20:48 +0900)
committerBo Peng <pengbo@sraoss.co.jp>
Mon, 13 Jun 2022 11:48:46 +0000 (20:48 +0900)
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.

14 files changed:
doc.ja/src/sgml/example-AWS.sgml
doc.ja/src/sgml/example-cluster.sgml
doc.ja/src/sgml/watchdog.sgml
doc/src/sgml/example-AWS.sgml
doc/src/sgml/example-cluster.sgml
doc/src/sgml/watchdog.sgml
src/config/pool_config_variables.c
src/include/pool_config.h
src/sample/pgpool.conf.sample-stream
src/utils/pool_process_reporting.c
src/watchdog/watchdog.c
src/watchdog/wd_escalation.c
src/watchdog/wd_if.c
src/watchdog/wd_utils.c

index b571be755a6e58d1d595f165329cd1a5cc404aa5..bc5e689e0b521d5bd15801d382cf0b105e6846fe 100644 (file)
 
   <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'
index 80100fcd8129ea379ed66751a807502f32548c68..a20dab6ab14a2129993283986da9af8975357046 100644 (file)
@@ -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>
index 89bf879747bf418d672c5c93ea570d1291edd9d4..f212d105a082f5d7f56a3c67d05727f23a9adc30 100644 (file)
 
   <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>
       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>のようにコマンドとパラメータを指定します。
       <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>
       このパラメータは、サーバ起動時にのみ設定できます。
       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>のようにコマンドとパラメータを指定します。
       <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>
       <!--
       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>のようにコマンドとパラメータを指定します。
       <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>
       <!--
index 111e420fc10b937566cafc0e6e6588737ba47648..0b33306fef76d13981bc2e7a6e5c2fbd532a7563 100644 (file)
@@ -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'
index a6bf26af088ef21523a43de8a931bd97892563a2..8f894afd49c996f2f3bd8a281e27ddc0f8b45258 100644 (file)
@@ -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>
index c09f3bf2042bb3adedc141281b66a7adf3af63e6..e8d5f6d7f0828043a18aa81bf068945b462276f1 100644 (file)
@@ -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.
index a138e382ecaff70983839ddcb79a320be4805653..90446bd795ebbfed3d3e5eb5dd297bf6594f69fd 100644 (file)
@@ -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 = "";
index 32f841b6fbe193009f03621873abe8d19c41ecfb..13b3aa3d7e5a5eb782e6d7e9d68b096e977874de 100644 (file)
@@ -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 */
index 248f46516090ce3ba789f737cc0005001207c60d..312014a4c8478b18e8746d41e92de660c674cc2a 100644 (file)
@@ -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)
index 5f2e40c3041184c5ed6ab6ef6ecd5a0b63295d3e..2f9157a44339dfa71158bc0b668b07ae55a30e1a 100644 (file)
@@ -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++;
 
index 95d3da1c0942b8e9ca5492c46df6ac5eaf98292c..d7001df7d27f4601744628a91ad0479f4bfcba1e 100644 (file)
@@ -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;
index 9acd4e49ec22e270027e6c8c901add44b0b91dc8..b0d01ecb6f8ae1ddda9ac818a391c2ba6f62422c 100644 (file)
@@ -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,
index 1de2337e281efb15c27a73c18a94605379e91dd3..f206ec9b317edf41dd9fcfdf344e9f63ece0d00d 100644 (file)
@@ -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 == ' ')
index d9d8c71531da52c158e911d408607a6970c476f8..a00f541b2102d72f548e5c8ed62a41b521258f0d 100644 (file)
@@ -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 */