[pgpool-committers: 10165] pgpool: Feature: Add new PCP command to invalidate query cache.
Tatsuo Ishii
ishii at postgresql.org
Tue Oct 15 09:28:21 JST 2024
Feature: Add new PCP command to invalidate query cache.
Previously it was not possible to invalidate query cache without
restarting pgpool. This commit adds new PCP command
"pcp_invalidate_query_cache" to invalidate query cache without
restarting pgpool. Note this command only places a query cache
invalidate request on shared the shared memory. The actual
invalidation is performed by pgpool child process.
The reasons for the PCP process cannot remove cache directly are:
1) the connection handle to memcached server is not managed by PCP
process.
2) removing shared memory query cache needs an interlock using
pool_shmem_ock() which may not work well on PCP process. Also a
function used here (pool_clear_memory_cache()) uses PG_TRY, which is
only usable in pgpool child process.
If pgpool child process finds such a request, the process invalidates
all query cache on the shared memory. If the query cache storage is
memcached, then pgpool issues memcached_flush() so that all query
cache on memcached are flushed immediately.
Note that the timing for pgpool child process to check the
invalidation request is after processing current query or response
from backend. This means that if all pgpool child process sit idle,
the request will not be processed until any of them receives a
messages from either frontend or backend.
Another note is, about query cache statistics shown by "show
pool_cache" command. Since the cache invalidation does not clear the
statistics, some of them (num_cache_hits and num_selects) continue to
increase even after the cache invalidation. Initializing the
statistics at the same could be possible but I am not sure if all
users want to do it.
Discussion:https://www.pgpool.net/pipermail/pgpool-hackers/2024-October/004525.html
Branch
------
master
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=09d4e59c55408e435c8a6232426c07a384d5c8de
Modified Files
--------------
doc.ja/src/sgml/ref/allfiles.sgml | 1 +
doc.ja/src/sgml/reference.sgml | 1 +
doc/src/sgml/ref/allfiles.sgml | 1 +
doc/src/sgml/reference.sgml | 1 +
src/include/pcp/libpcp_ext.h | 3 +-
src/include/pool.h | 1 +
src/include/query_cache/pool_memqcache.h | 2 +-
src/libs/pcp/pcp.c | 168 ++++++++++++++----------
src/pcp_con/pcp_worker.c | 116 ++++++++++------
src/protocol/CommandComplete.c | 35 -----
src/protocol/pool_process_query.c | 16 +++
src/query_cache/pool_memqcache.c | 36 ++++-
src/test/regression/tests/006.memqcache/test.sh | 32 +++++
src/tools/pcp/Makefile.am | 5 +-
src/tools/pcp/pcp_frontend_client.c | 37 +++---
15 files changed, 290 insertions(+), 165 deletions(-)
More information about the pgpool-committers
mailing list