pgpool2.git / summary / log / commit / refs

commit    63803cf8ee83f9735e608aac3c2c8436b4ce6bcc
Author:   Yugo Nagata <nagata@sraoss.co.jp>
Date:     Fri Apr 26 08:32:53 2013 +0000

    Add wd_escalation_command option
    
    This specifies command which is executed at escalation on the new
    active pgpool server before virtual IP is brought up.


pgpool.conf.sample | 2 ++ pool_config.c | 21 +++++++++++++++++++++ pool_config.h | 1 + pool_config.l | 21 +++++++++++++++++++++ watchdog/wd_packet.c | 6 ++++++ 5 files changed, 51 insertions(+) diff --git a/pgpool.conf.sample b/pgpool.conf.sample index 2f4052042..4fa407fed 100644 --- a/pgpool.conf.sample +++ b/pgpool.conf.sample @@ -439,6 +439,8 @@ clear_memqcache_on_escalation = on # This should be off if client connects to pgpool # not using virtual IP. # (change requires restart) +wd_escalation_command = '' + # Executes this command at escalation on new active pgpool. trusted_servers = '' # trusted server list which are used diff --git a/pool_config.c b/pool_config.c index 40b34fa57..36ef481ec 100644 --- a/pool_config.c +++ b/pool_config.c @@ -1781,6 +1781,7 @@ int pool_init_config(void) */ pool_config->use_watchdog = 0; pool_config->clear_memqcache_on_escalation = 1; + pool_config->wd_escalation_command = ""; pool_config->trusted_servers = ""; pool_config->delegate_IP = ""; res = gethostname(localhostname,sizeof(localhostname)); @@ -3519,6 +3520,26 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context) pool_config->clear_memqcache_on_escalation = v; } + else if (!strcmp(key, "wd_escalation_command") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->wd_escalation_command = str; + } + else if (!strcmp(key, "trusted_servers") && CHECK_CONTEXT(INIT_CONFIG, context)) { char *str; diff --git a/pool_config.h b/pool_config.h index 9f5874715..1145f1ef4 100644 --- a/pool_config.h +++ b/pool_config.h @@ -225,6 +225,7 @@ typedef struct { int use_watchdog; /* if non 0, use watchdog */ char *watchdog_mode; /* mode of lifecheck mode. 'udp' or 'query' */ int clear_memqcache_on_escalation; /* if no 0, clear query cache on shmem when escalating */ + char *wd_escalation_command; /* Executes this command at escalation on new active pgpool.*/ char *wd_hostname; /* watchdog hostname */ int wd_port; /* watchdog port */ WdDesc * other_wd; /* watchdog lists */ diff --git a/pool_config.l b/pool_config.l index 71f67b912..970e1125c 100644 --- a/pool_config.l +++ b/pool_config.l @@ -234,6 +234,7 @@ int pool_init_config(void) */ pool_config->use_watchdog = 0; pool_config->clear_memqcache_on_escalation = 1; + pool_config->wd_escalation_command = ""; pool_config->trusted_servers = ""; pool_config->delegate_IP = ""; res = gethostname(localhostname,sizeof(localhostname)); @@ -1972,6 +1973,26 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context) pool_config->clear_memqcache_on_escalation = v; } + else if (!strcmp(key, "wd_escalation_command") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->wd_escalation_command = str; + } + else if (!strcmp(key, "trusted_servers") && CHECK_CONTEXT(INIT_CONFIG, context)) { char *str; diff --git a/watchdog/wd_packet.c b/watchdog/wd_packet.c index 349d8118a..7d9e08e2e 100644 --- a/watchdog/wd_packet.c +++ b/watchdog/wd_packet.c @@ -948,6 +948,12 @@ wd_escalation(void) pool_clear_memory_cache(); } + /* execute escalation command */ + if (strlen(pool_config->wd_escalation_command)) + { + system(pool_config->wd_escalation_command); + } + /* interface up as delegate IP */ wd_IP_up(); /* set master status to the wd list */ [parent: 8bf1483d091f]