pgpool2.git / summary / log / commit / refs

commit    8bf1483d091faa0b96c0cc22604531cf68da7bfb
Author:   Yugo Nagata <nagata@sraoss.co.jp>
Date:     Fri Apr 26 08:17:56 2013 +0000

    Add clear_memqcache_on_escalation option
    
    If this is on, all the query caches on shared memory are cleared
    when standby pgpool escalates to active (virtual IP holder).
    This option should be off when clients connect to pgpool not using
    virtual IP, such like multi-master configuration.


pgpool.conf.sample | 9 +++++++++ pool_config.c | 14 ++++++++++++++ pool_config.h | 49 ++++++++++++++++++++++++------------------------- pool_config.l | 14 ++++++++++++++ watchdog/wd_packet.c | 6 ++---- 5 files changed, 63 insertions(+), 29 deletions(-) diff --git a/pgpool.conf.sample b/pgpool.conf.sample index c22c86733..2f4052042 100644 --- a/pgpool.conf.sample +++ b/pgpool.conf.sample @@ -431,6 +431,15 @@ use_watchdog = off watchdog_mode='udp' # Mode of watchdog lifecheck ('udp' or 'query') # (change requires restart) + +clear_memqcache_on_escalation = on + # Clear all the query cache on shared memory + # when standby pgpool escalate to active pgpool + # (= virtual IP holder). + # This should be off if client connects to pgpool + # not using virtual IP. + # (change requires restart) + trusted_servers = '' # trusted server list which are used # to confirm network connection diff --git a/pool_config.c b/pool_config.c index 783622071..40b34fa57 100644 --- a/pool_config.c +++ b/pool_config.c @@ -1780,6 +1780,7 @@ int pool_init_config(void) * add for watchdog */ pool_config->use_watchdog = 0; + pool_config->clear_memqcache_on_escalation = 1; pool_config->trusted_servers = ""; pool_config->delegate_IP = ""; res = gethostname(localhostname,sizeof(localhostname)); @@ -3505,6 +3506,19 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context) pool_config->use_watchdog = v; } + else if (!strcmp(key, "clear_memqcache_on_escalation") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->clear_memqcache_on_escalation = v; + } + else if (!strcmp(key, "trusted_servers") && CHECK_CONTEXT(INIT_CONFIG, context)) { char *str; diff --git a/pool_config.h b/pool_config.h index c8060de03..9f5874715 100644 --- a/pool_config.h +++ b/pool_config.h @@ -222,32 +222,31 @@ typedef struct { /* * add for watchdog */ - int use_watchdog; /* if non 0, use watchdog */ - char *wd_hostname; /* watchdog hostname */ - int wd_port; /* watchdog port */ - WdDesc * other_wd; /* watchdog lists */ - char * trusted_servers; /* icmp reachable server list (A,B,C) */ - char * delegate_IP; /* delegate IP address */ - int wd_interval; /* lifecheck interval (sec) */ - char * ping_path; /* path to ping command */ - 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 */ - char *wd_lifecheck_dbname; /* Database name connected for lifecheck */ - char *wd_lifecheck_user; /* PostgreSQL user name for watchdog */ - char *wd_lifecheck_password; /* password for watchdog user */ - - char *watchdog_mode; - int wd_udp_keepalive; - int wd_udp_deadtime; - int wd_udp_port; - char *wd_authkey; + 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_hostname; /* watchdog hostname */ + int wd_port; /* watchdog port */ + WdDesc * other_wd; /* watchdog lists */ + char * trusted_servers; /* icmp reachable server list (A,B,C) */ + char * delegate_IP; /* delegate IP address */ + int wd_interval; /* lifecheck interval (sec) */ + char *wd_authkey; /* Authentication key for watchdog communication */ + char * ping_path; /* path to ping command */ + 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 */ + char *wd_lifecheck_dbname; /* Database name connected for lifecheck */ + char *wd_lifecheck_user; /* PostgreSQL user name for watchdog */ + char *wd_lifecheck_password; /* password for watchdog user */ + int wd_udp_port; /* Port number for UDP heartbeat lifecheck */ + int wd_udp_keepalive; /* Interval time of sending UDP heartbeat signal (sec) */ + int wd_udp_deadtime; /* Deadtime interval for UDP heartbeat signal (sec) */ } POOL_CONFIG; - typedef enum { INIT_CONFIG = 1, /* 0x01 */ RELOAD_CONFIG = 2 /* 0x02 */ diff --git a/pool_config.l b/pool_config.l index 38ae80d31..71f67b912 100644 --- a/pool_config.l +++ b/pool_config.l @@ -233,6 +233,7 @@ int pool_init_config(void) * add for watchdog */ pool_config->use_watchdog = 0; + pool_config->clear_memqcache_on_escalation = 1; pool_config->trusted_servers = ""; pool_config->delegate_IP = ""; res = gethostname(localhostname,sizeof(localhostname)); @@ -1958,6 +1959,19 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context) pool_config->use_watchdog = v; } + else if (!strcmp(key, "clear_memqcache_on_escalation") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->clear_memqcache_on_escalation = v; + } + 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 38b4b157f..349d8118a 100644 --- a/watchdog/wd_packet.c +++ b/watchdog/wd_packet.c @@ -941,15 +941,13 @@ wd_escalation(void) pool_log("wd_escalation: escalated to master pgpool"); /* clear shared memory cache */ - if (pool_config->memory_cache_enabled && - pool_is_shmem_cache()) + if (pool_config->memory_cache_enabled && pool_is_shmem_cache() && + pool_config->clear_memqcache_on_escalation) { pool_log("wd_escalation: clear all the query cache on shared memory"); pool_clear_memory_cache(); } - system("ls -al"); - /* interface up as delegate IP */ wd_IP_up(); /* set master status to the wd list */ [parent: 969bb69b1bbd]