pgpool2.git / summary / log / commit / refs

commit    d7b97274dfb0518b483a9540e7ffa49ba4bb5de2
Author:   Yugo Nagata <nagata@sraoss.co.jp>
Date:     Fri Jun 21 10:14:55 2013 +0000

    Fix not to bring up virtual IP when delegate_IP parameter is emply.


pgpool.conf.sample | 1 + pgpool.conf.sample-master-slave | 1 + pgpool.conf.sample-replication | 1 + pgpool.conf.sample-stream | 1 + watchdog/watchdog.c | 6 +----- watchdog/wd_child.c | 3 ++- watchdog/wd_if.c | 6 ++++++ watchdog/wd_init.c | 5 +++-- watchdog/wd_lifecheck.c | 3 ++- watchdog/wd_packet.c | 15 ++++++++++++--- 10 files changed, 30 insertions(+), 12 deletions(-) diff --git a/pgpool.conf.sample b/pgpool.conf.sample index a50092f6e..eb0a2075f 100644 --- a/pgpool.conf.sample +++ b/pgpool.conf.sample @@ -464,6 +464,7 @@ wd_authkey = '' delegate_IP = '' # delegate IP address + # If this is empty, virtual IP never bring up. # (change requires restart) ifconfig_path = '/sbin' # ifconfig command path diff --git a/pgpool.conf.sample-master-slave b/pgpool.conf.sample-master-slave index e4b975500..e34ec4a85 100644 --- a/pgpool.conf.sample-master-slave +++ b/pgpool.conf.sample-master-slave @@ -464,6 +464,7 @@ wd_authkey = '' delegate_IP = '' # delegate IP address + # If this is empty, virtual IP never bring up. # (change requires restart) ifconfig_path = '/sbin' # ifconfig command path diff --git a/pgpool.conf.sample-replication b/pgpool.conf.sample-replication index 114a8114a..a40bb9d08 100644 --- a/pgpool.conf.sample-replication +++ b/pgpool.conf.sample-replication @@ -463,6 +463,7 @@ wd_authkey = '' delegate_IP = '' # delegate IP address + # If this is empty, virtual IP never bring up. # (change requires restart) ifconfig_path = '/sbin' # ifconfig command path diff --git a/pgpool.conf.sample-stream b/pgpool.conf.sample-stream index 8d74931af..501851a0c 100644 --- a/pgpool.conf.sample-stream +++ b/pgpool.conf.sample-stream @@ -463,6 +463,7 @@ wd_authkey = '' delegate_IP = '' # delegate IP address + # If this is empty, virtual IP never bring up. # (change requires restart) ifconfig_path = '/sbin' # ifconfig command path diff --git a/watchdog/watchdog.c b/watchdog/watchdog.c index 3b1624a98..60bcd080c 100644 --- a/watchdog/watchdog.c +++ b/watchdog/watchdog.c @@ -103,11 +103,7 @@ wd_check_config(void) pool_error("wd_check_config: there is no other pgpools setting."); status = WD_NG; } - if (strlen(pool_config->delegate_IP) == 0) - { - pool_error("wd_check_config: delegate_IP is empty"); - status = WD_NG; - } + if (strlen(pool_config->wd_authkey) > MAX_PASSWORD_SIZE) { pool_error("wd_check_config: wd_authkey length can't be larger than %d", diff --git a/watchdog/wd_child.c b/watchdog/wd_child.c index 343cd9898..0370792b6 100644 --- a/watchdog/wd_child.c +++ b/watchdog/wd_child.c @@ -233,7 +233,8 @@ wd_send_response(int sock, WdPacket * recv_pack) { /* resign master server */ pool_log("wd_send_response: WD_DECLARE_NEW_MASTER received and resign master server"); - wd_IP_down(); + if (strlen(pool_config->delegate_IP) != 0) + wd_IP_down(); wd_set_myself(NULL, WD_NORMAL); } send_packet.packet_no = WD_READY; diff --git a/watchdog/wd_if.c b/watchdog/wd_if.c index ef9d6a549..9c9eaf768 100644 --- a/watchdog/wd_if.c +++ b/watchdog/wd_if.c @@ -49,6 +49,9 @@ wd_IP_up(void) char path[WD_MAX_PATH_LEN]; char cmd[128]; + if (strlen(pool_config->delegate_IP) == 0) + return WD_NG; + if (WD_List->delegate_ip_flag == 0) { WD_List->delegate_ip_flag = 1; @@ -72,6 +75,9 @@ wd_IP_down(void) char cmd[128]; int i; + if (strlen(pool_config->delegate_IP) == 0) + return WD_NG; + if (WD_List->delegate_ip_flag == 1) { WD_List->delegate_ip_flag = 0; diff --git a/watchdog/wd_init.c b/watchdog/wd_init.c index 4c6bcd53d..6bfc69e33 100644 --- a/watchdog/wd_init.c +++ b/watchdog/wd_init.c @@ -108,9 +108,10 @@ wd_init(void) } /* check existence of master pgpool */ - if (wd_is_exist_master() == NULL ) + if (wd_is_exist_master() == NULL) { - if (!wd_is_unused_ip(pool_config->delegate_IP)) + if (strlen(pool_config->delegate_IP) != 0 && + !wd_is_unused_ip(pool_config->delegate_IP)) { pool_error("wd_init: delegate_IP %s already exists", pool_config->delegate_IP); return WD_NG; diff --git a/watchdog/wd_lifecheck.c b/watchdog/wd_lifecheck.c index b57d221c8..c8605f65f 100644 --- a/watchdog/wd_lifecheck.c +++ b/watchdog/wd_lifecheck.c @@ -126,7 +126,8 @@ wd_lifecheck(void) { pool_error("wd_lifecheck: failed to connect to any trusted servers"); - if (WD_MYSELF->status == WD_MASTER) + if (WD_MYSELF->status == WD_MASTER && + strlen(pool_config->delegate_IP) != 0) { wd_IP_down(); } diff --git a/watchdog/wd_packet.c b/watchdog/wd_packet.c index af18601ce..78ce5eee1 100644 --- a/watchdog/wd_packet.c +++ b/watchdog/wd_packet.c @@ -940,7 +940,7 @@ wd_escalation(void) { int rtn; - pool_log("wd_escalation: escalated to master pgpool"); + pool_log("wd_escalation: escalatting to master pgpool"); /* clear shared memory cache */ if (pool_config->memory_cache_enabled && pool_is_shmem_cache() && @@ -957,7 +957,9 @@ wd_escalation(void) } /* interface up as delegate IP */ - wd_IP_up(); + if (strlen(pool_config->delegate_IP) != 0) + wd_IP_up(); + /* set master status to the wd list */ wd_set_wd_list(pool_config->wd_hostname, pool_config->port, pool_config->wd_port, pool_config->delegate_IP, @@ -967,7 +969,7 @@ wd_escalation(void) rtn = wd_declare(); if (rtn == WD_OK) { - pool_log("wd_escalation: escalated to delegate_IP holder"); + pool_log("wd_escalation: escalated to master pgpool successfully"); } return rtn; @@ -999,6 +1001,7 @@ wd_send_failback_request(int node_id) int rtn = 0; int n = node_id; + /* if failback packet is received already, do nothing */ if (wd_chk_node_mask(WD_FAILBACK_REQUEST,&n,1)) { return WD_OK; @@ -1014,10 +1017,12 @@ wd_degenerate_backend_set(int *node_id_set, int count) { int rtn = 0; + /* if degenerate packet is received already, do nothing */ if (wd_chk_node_mask(WD_DEGENERATE_BACKEND,node_id_set,count)) { return WD_OK; } + /* send degenerate packet */ rtn = wd_send_node_packet(WD_DEGENERATE_BACKEND, node_id_set, count); return rtn; @@ -1029,10 +1034,12 @@ wd_promote_backend(int node_id) int rtn = 0; int n = node_id; + /* if promote packet is received already, do nothing */ if (wd_chk_node_mask(WD_PROMOTE_BACKEND,&n,1)) { return WD_OK; } + /* send promote packet */ rtn = wd_send_node_packet(WD_PROMOTE_BACKEND, &n, 1); return rtn; @@ -1074,6 +1081,7 @@ wd_send_lock_packet(WD_PACKET_NO packet_no, WD_LOCK_ID lock_id) return rtn; } +/* check mask, and if maskted return 1 and clear it, otherwise return 0 */ static int wd_chk_node_mask (WD_PACKET_NO packet_no, int *node_id_set, int count) { @@ -1094,6 +1102,7 @@ wd_chk_node_mask (WD_PACKET_NO packet_no, int *node_id_set, int count) return rtn; } +/* set mask */ int wd_set_node_mask (WD_PACKET_NO packet_no, int *node_id_set, int count) { [parent: 7b439244c5a6]