pgpool2.git / summary / log / commit / refs

commit    50a10bfc45dbb60636883d20425fd069e4bd093f
Author:   at.mitani <at.mitani@gmail.com>
Date:     Wed Jun 20 02:23:16 2012 +0000

    Applied Nagata's patch and suggestion into watchdogs.


pgpool.conf | 2 +- pgpool.conf.sample | 5 +++++ pool_config.c | 2 ++ pool_config.h | 2 ++ pool_config.l | 2 ++ pool_process_reporting.c | 10 ++++++++++ watchdog/watchdog.h | 3 ++- watchdog/wd_child.c | 2 +- watchdog/wd_if.c | 27 +++++++++++++++------------ watchdog/wd_lifecheck.c | 9 +++++---- 10 files changed, 45 insertions(+), 19 deletions(-) diff --git a/pgpool.conf b/pgpool.conf index becebb46e..9158bec2b 100644 --- a/pgpool.conf +++ b/pgpool.conf @@ -453,7 +453,7 @@ other_pgpool_port0 = 9999 # Port number for othet pgpool 0 other_wd_port0 = 9000 # Port number for othet watchdog 0 -#other_pgpool_hostname1 = 'vm2' +#other_pgpool_hostname1 = 'vm1' #other_pgpool_port1 = 9999 #other_wd_port1 = 9000 diff --git a/pgpool.conf.sample b/pgpool.conf.sample index 024c7d2af..31fda8eb3 100644 --- a/pgpool.conf.sample +++ b/pgpool.conf.sample @@ -441,6 +441,11 @@ if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0' # startup delegate IP command if_down_cmd = 'ifconfig eth0:0 down' # shutdown delegate IP command + +arping_path = '/usr/sbin' # arping command path + +arping_cmd = 'arping -U $_IP_$ -w 1' + # arping command wd_life_point = 3 # lifecheck retry times wd_lifecheck_query = 'SELECT 1' diff --git a/pool_config.c b/pool_config.c index 1787c2258..f1f0dff9c 100644 --- a/pool_config.c +++ b/pool_config.c @@ -1967,6 +1967,8 @@ int pool_init_config(void) pool_config->ifconfig_path = "/sbin"; pool_config->if_up_cmd = "ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0"; pool_config->if_down_cmd = "ifconfig eth0:0 down"; + pool_config->arping_path = "/usr/sbin"; + pool_config->arping_cmd = "arping -U $_IP_$ -w 1"; pool_config->wd_life_point = 3; pool_config->wd_lifecheck_query = "SELECT 1"; diff --git a/pool_config.h b/pool_config.h index a36befe98..4321d1c04 100644 --- a/pool_config.h +++ b/pool_config.h @@ -229,6 +229,8 @@ typedef struct { char * ifconfig_path; /* path to ifconfig command */ char * if_up_cmd; /* ifup command */ char * if_down_cmd; /* ifdown command */ + char * arping_path; /* path to arping command */ + char * arping_cmd; /* arping command */ int wd_life_point; /* life point (retry times at lifecheck) */ char * wd_lifecheck_query; /* lifecheck query */ } POOL_CONFIG; diff --git a/pool_config.l b/pool_config.l index eeea265f6..9d68a8ad3 100644 --- a/pool_config.l +++ b/pool_config.l @@ -242,6 +242,8 @@ int pool_init_config(void) pool_config->ifconfig_path = "/sbin"; pool_config->if_up_cmd = "ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0"; pool_config->if_down_cmd = "ifconfig eth0:0 down"; + pool_config->arping_path = "/usr/sbin"; + pool_config->arping_cmd = "arping -U $_IP_$ -w 1"; pool_config->wd_life_point = 3; pool_config->wd_lifecheck_query = "SELECT 1"; diff --git a/pool_process_reporting.c b/pool_process_reporting.c index 3691ae09d..d0469bfcb 100644 --- a/pool_process_reporting.c +++ b/pool_process_reporting.c @@ -665,6 +665,16 @@ POOL_REPORT_CONFIG* get_config(int *nrows) strncpy(status[i].desc, "virtual interface down command with full parameters", POOLCONFIG_MAXDESCLEN); i++; + strncpy(status[i].name, "arping_path", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->arping_path); + strncpy(status[i].desc, "path to arping command", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "arping_cmd", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->arping_cmd); + strncpy(status[i].desc, "send ARP REQUESTi to neighbour host", POOLCONFIG_MAXDESCLEN); + i++; + strncpy(status[i].name, "wd_life_point", POOLCONFIG_MAXNAMELEN); snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->wd_life_point); strncpy(status[i].desc, "retry times of life check", POOLCONFIG_MAXDESCLEN); diff --git a/watchdog/watchdog.h b/watchdog/watchdog.h index 0332c7a8d..31a0557e9 100644 --- a/watchdog/watchdog.h +++ b/watchdog/watchdog.h @@ -81,7 +81,8 @@ typedef struct { char hostname[WD_MAX_HOST_NAMELEN]; /* host name */ int pgpool_port; /* pgpool port */ int wd_port; /* watchdog port */ - int life; /* life point */ + int life; /* life point */ + int delegate_ip; /* delegate IP flag */ }WdInfo; typedef struct { diff --git a/watchdog/wd_child.c b/watchdog/wd_child.c index 56bf9d5e3..b39c3573b 100644 --- a/watchdog/wd_child.c +++ b/watchdog/wd_child.c @@ -64,7 +64,7 @@ wd_child(int fork_wait_time) signal(SIGTERM, wd_child_exit); signal(SIGINT, wd_child_exit); signal(SIGQUIT, wd_child_exit); - signal(SIGCHLD, wd_child_exit); + signal(SIGCHLD, SIG_IGN); signal(SIGHUP, SIG_IGN); signal(SIGUSR1, SIG_IGN); signal(SIGUSR2, SIG_IGN); diff --git a/watchdog/wd_if.c b/watchdog/wd_if.c index 667c8db43..bbb3a5a98 100644 --- a/watchdog/wd_if.c +++ b/watchdog/wd_if.c @@ -37,44 +37,47 @@ int wd_IP_up(void); int wd_IP_down(void); -static int exec_ifconfig(char * command); -static int ip_flg = 0; +static int exec_ifconfig(char * path,char * command); int wd_IP_up(void) { int rtn; - if (ip_flg == 0) + char path[128]; + if (WD_List->delegate_ip == 0) { - rtn = exec_ifconfig(pool_config->if_up_cmd); + WD_List->delegate_ip = 1; + sprintf(path,"%s/ifconfig",pool_config->ifconfig_path); + rtn = exec_ifconfig(path,pool_config->if_up_cmd); + sprintf(path,"%s/arping",pool_config->arping_path); + rtn = exec_ifconfig(path,pool_config->arping_cmd); } - ip_flg = 1; return rtn; } int wd_IP_down(void) { int rtn; - if (ip_flg == 1) + char path[128]; + if (WD_List->delegate_ip == 1) { - rtn = exec_ifconfig(pool_config->if_down_cmd); + WD_List->delegate_ip = 0; + sprintf(path,"%s/ifconfig",pool_config->ifconfig_path); + rtn = exec_ifconfig(path,pool_config->if_down_cmd); } - ip_flg = 0; return rtn; } static int -exec_ifconfig(char * command) +exec_ifconfig(char * path,char * command) { int pfd[2]; int status; char * args[24]; int pid, i = 0; - char ifconfig_path[128]; char buf[256]; char *bp, *ep; - sprintf(ifconfig_path,"%s/ifconfig",pool_config->ifconfig_path); if (pipe(pfd) == -1) { pool_error("pipe open error:%s",strerror(errno)); @@ -123,7 +126,7 @@ exec_ifconfig(char * command) close(STDOUT_FILENO); dup2(pfd[1], STDOUT_FILENO); close(pfd[0]); - status = execv(ifconfig_path,args); + status = execv(path,args); exit(0); } else diff --git a/watchdog/wd_lifecheck.c b/watchdog/wd_lifecheck.c index ff7181694..e0743816e 100644 --- a/watchdog/wd_lifecheck.c +++ b/watchdog/wd_lifecheck.c @@ -48,7 +48,8 @@ is_wd_lifecheck_ready(void) { PGconn * conn = NULL; PGresult * res = (PGresult *)NULL; - int status = WD_OK; + int status; + int rtn = WD_OK; WdInfo * p = WD_List; while (p->status != WD_END) { @@ -65,17 +66,17 @@ is_wd_lifecheck_ready(void) if ((status == PGRES_NONFATAL_ERROR )|| (status == PGRES_FATAL_ERROR )) { - status = WD_NG; + rtn = WD_NG; } PQfinish(conn); } else { - status = WD_NG; + rtn = WD_NG; } p ++; } - return status; + return rtn; } int [parent: 5d83b3d07557]