pgpool2.git / summary / log / commit / refs
commit 835f0e28160cafa262262c2ffe058d6832e43ae3
Author: Yugo Nagata <nagata@sraoss.co.jp>
Date: Fri Apr 20 07:23:46 2012 +0000
Add a new option "memqcache_auto_cache_invalidation" to pgpool.conf.
If true, invalidation of query cache is triggered by corresponding
DDL/DML/DCL(and memqcache_expire). If false, it is only triggered
by memqcache_expire. True by default.
doc/pgpool-en.html | 9 +++++++++
doc/pgpool-ja.html | 8 ++++++++
pgpool.conf.sample | 5 +++++
pgpool.conf.sample-master-slave | 5 +++++
pgpool.conf.sample-replication | 5 +++++
pgpool.conf.sample-stream | 5 +++++
pool_config.h | 3 +++
pool_config.l | 13 +++++++++++++
pool_memqcache.c | 14 +++++++++-----
pool_process_reporting.c | 5 +++++
10 files changed, 67 insertions(+), 5 deletions(-)
diff --git a/doc/pgpool-en.html b/doc/pgpool-en.html
index 338066d42..2a666ebf1 100644
--- a/doc/pgpool-en.html
+++ b/doc/pgpool-en.html
@@ -2313,6 +2313,15 @@ Memory cache entry life time specified in seconds. Default is 60.
memqcache_expire = 60
</pre>
+<p>
+If true, invalidation of query cache is triggered by corresponding
+DDL/DML/DCL(and memqcache_expire). If false, it is only triggered
+by memqcache_expire. True by default.
+</p>
+<pre>
+memqcache_auto_cache_invalidation = true
+</pre>
+
<p>
Maximum SELECT result size in bytes. If exceeds this value, the result is not cached.
</p>
diff --git a/doc/pgpool-ja.html b/doc/pgpool-ja.html
index 72c1db27a..1fbdd045c 100644
--- a/doc/pgpool-ja.html
+++ b/doc/pgpool-ja.html
@@ -2221,6 +2221,14 @@ memqcache_max_num_cache = 100
memqcache_expire = 60
</pre>
+<p>
+DDL/DML/DCL $B$,<B9T$5$l$?>l9g!J$H<wL?$,2a$.$?>l9g!K$K%/%(%j%-%c%C%7%e$NL58z2=$r$9$k>l9g$O!"0J2<$N$h$&$K@_Dj$7$^$9!#(B<br />
+false $B$K@_Dj$9$k$H!"<wL?$r2a$.$?>l9g$K$N$_%/%(%j%-%c%C%7%e$rL58z2=$7$^$9!#%G%U%)%k%H$O(B true $B$G$9!#(B
+</p>
+<pre>
+memqcache_auto_cache_invalidation = true
+</pre>
+
<p>
$B%-%c%C%7%e$r5vMF$9$k(BSELECT$BJ8$N<B9T7k2L$N:GBg%5%$%:$O!"0J2<$N$h$&$K@_Dj$7$^$9!#C10L$O%P%$%H$G$9!#(B
diff --git a/pgpool.conf.sample b/pgpool.conf.sample
index fb600ae2e..38ad7d267 100644
--- a/pgpool.conf.sample
+++ b/pgpool.conf.sample
@@ -463,6 +463,11 @@ memqcache_max_num_cache=131072
# Memory cache entry life time specified in seconds. 60 by default.
memqcache_expire=60
+# If true, invalidation of query cache is triggered by corresponding
+# DDL/DML/DCL(and memqcache_expire). If false, it is only triggered
+# by memqcache_expire. True by default.
+memqcache_auto_cache_invalidation = true
+
# Maximum SELECT result size in bytes.
memqcache_maxcache=1024
diff --git a/pgpool.conf.sample-master-slave b/pgpool.conf.sample-master-slave
index a4436e9d6..fee38d99b 100644
--- a/pgpool.conf.sample-master-slave
+++ b/pgpool.conf.sample-master-slave
@@ -458,6 +458,11 @@ memqcache_max_num_cache=131072
# Memory cache entry life time specified in seconds. 60 by default.
memqcache_expire=60
+# If true, invalidation of query cache is triggered by corresponding
+# DDL/DML/DCL(and memqcache_expire). If false, it is only triggered
+# by memqcache_expire. True by default.
+memqcache_auto_cache_invalidation = true
+
# Maximum SELECT result size in bytes.
memqcache_maxcache=1024
diff --git a/pgpool.conf.sample-replication b/pgpool.conf.sample-replication
index 0e1a43671..d1ca317db 100644
--- a/pgpool.conf.sample-replication
+++ b/pgpool.conf.sample-replication
@@ -458,6 +458,11 @@ memqcache_max_num_cache=131072
# Memory cache entry life time specified in seconds. 60 by default.
memqcache_expire=60
+# If true, invalidation of query cache is triggered by corresponding
+# DDL/DML/DCL(and memqcache_expire). If false, it is only triggered
+# by memqcache_expire. True by default.
+memqcache_auto_cache_invalidation = true
+
# Maximum SELECT result size in bytes.
memqcache_maxcache=1024
diff --git a/pgpool.conf.sample-stream b/pgpool.conf.sample-stream
index 2c92b090f..855889bf4 100644
--- a/pgpool.conf.sample-stream
+++ b/pgpool.conf.sample-stream
@@ -458,6 +458,11 @@ memqcache_max_num_cache=131072
# Memory cache entry life time specified in seconds. 60 by default.
memqcache_expire=60
+# If true, invalidation of query cache is triggered by corresponding
+# DDL/DML/DCL(and memqcache_expire). If false, it is only triggered
+# by memqcache_expire. True by default.
+memqcache_auto_cache_invalidation = true
+
# Maximum SELECT result size in bytes.
memqcache_maxcache=1024
diff --git a/pool_config.h b/pool_config.h
index a118bfd51..5fc86c448 100644
--- a/pool_config.h
+++ b/pool_config.h
@@ -196,6 +196,9 @@ typedef struct {
int memqcache_total_size; /* Total memory size in bytes for storing memory cache. Mandatory if memqcache_method=shmem. */
int memqcache_max_num_cache; /* Total number of cache entries. Mandatory if memqcache_method=shmem. */
int memqcache_expire; /* Memory cache entry life time specified in seconds. 60 by default. */
+ int memqcache_auto_cache_invalidation; /* If true, invalidation of query cache is triggered by corresponding */
+ /* DDL/DML/DCL(and memqcache_expire). If false, it is only triggered */
+ /* by memqcache_expire. True by default. */
int memqcache_maxcache; /* Maximum SELECT result size in bytes. */
int memqcache_cache_block_size; /* Cache block size in bytes. 8192 by default */
char *memqcache_oiddir; /* Tempory work directory to record table oids */
diff --git a/pool_config.l b/pool_config.l
index aaf3c301d..4c8c15cf4 100644
--- a/pool_config.l
+++ b/pool_config.l
@@ -224,6 +224,7 @@ int pool_init_config(void)
pool_config->memqcache_total_size = 10240;
pool_config->memqcache_max_num_cache = 100;
pool_config->memqcache_expire = 60;
+ pool_config->memqcache_auto_cache_invalidation = true;
pool_config->memqcache_maxcache = 512;
pool_config->memqcache_cache_block_size = 8192;
pool_config->memqcache_oiddir = "/var/log/pgpool/oiddir";
@@ -2066,6 +2067,18 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
}
pool_config->memqcache_max_num_cache = v;
}
+ else if (!strcmp(key, "memqcache_auto_cache_invalidation") && 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->memqcache_auto_cache_invalidation = v;
+ }
else if (!strcmp(key, "memqcache_maxcache") && CHECK_CONTEXT(INIT_CONFIG, context))
{
int v = atoi(yytext);
diff --git a/pool_memqcache.c b/pool_memqcache.c
index 47491cc27..8f78eda69 100644
--- a/pool_memqcache.c
+++ b/pool_memqcache.c
@@ -2784,11 +2784,15 @@ void pool_handle_query_cache(POOL_CONNECTION_POOL *backend, char *query, Node *n
{
int num_caches;
- /* Invalidate query cache */
- num_oids = pool_get_dml_table_oid(&oids);
POOL_SETMASK2(&BlockSig, &oldmask);
pool_shmem_lock();
- pool_invalidate_query_cache(num_oids, oids, true, 0);
+
+ /* Invalidate query cache */
+ if (pool_config->memqcache_auto_cache_invalidation)
+ {
+ num_oids = pool_get_dml_table_oid(&oids);
+ pool_invalidate_query_cache(num_oids, oids, true, 0);
+ }
/*
* If we have something in the query cache buffer, that means
@@ -2851,7 +2855,7 @@ void pool_handle_query_cache(POOL_CONNECTION_POOL *backend, char *query, Node *n
int dboid = session_context->query_context->dboid;
num_oids = pool_get_dropdb_table_oids(&oids, dboid);
- if (num_oids > 0)
+ if (num_oids > 0 && pool_config->memqcache_auto_cache_invalidation)
{
pool_shmem_lock();
pool_invalidate_query_cache(num_oids, oids, true, dboid);
@@ -2871,7 +2875,7 @@ void pool_handle_query_cache(POOL_CONNECTION_POOL *backend, char *query, Node *n
/* Extract table oids from buffer */
num_oids = pool_get_dml_table_oid(&oids);
- if (num_oids > 0)
+ if (num_oids > 0 && pool_config->memqcache_auto_cache_invalidation)
{
/*
* If we are not inside a transaction, we can
diff --git a/pool_process_reporting.c b/pool_process_reporting.c
index 08f616d0d..cf748ef05 100644
--- a/pool_process_reporting.c
+++ b/pool_process_reporting.c
@@ -579,6 +579,11 @@ POOL_REPORT_CONFIG* get_config(int *nrows)
strncpy(status[i].desc, "Memory cache entry life time specified in seconds. 60 by default", POOLCONFIG_MAXDESCLEN);
i++;
+ strncpy(status[i].name, "memqcache_auto_cache_invalidation", POOLCONFIG_MAXNAMELEN);
+ snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->memqcache_expire);
+ strncpy(status[i].desc, "If true, invalidation of query cache is triggered by corresponding DDL/DML/DCL(and memqcache_expire). If false, it is only triggered by memqcache_expire. True by default.", POOLCONFIG_MAXDESCLEN);
+ i++;
+
strncpy(status[i].name, "memqcache_maxcache", POOLCONFIG_MAXNAMELEN);
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->memqcache_maxcache);
strncpy(status[i].desc, "Maximum SELECT result size in bytes", POOLCONFIG_MAXDESCLEN);
[parent: f9a4c92bb653]