[pgpool-committers: 10439] pgpool: Fix query cache invalidation bug.

Tatsuo Ishii ishii at postgresql.org
Thu May 8 14:38:25 JST 2025


Fix query cache invalidation bug.

When an execute message is received, pgpool checks its max number of
rows paramter. If it's not zero, pgpool sets "partial_fetch" flag to
instruct pool_handle_query_cache() to not create query cache.  Problem
is, commit 2a99aa5d1 missed that even INSERT/UPDATE/DELETE sets the
execute message parameter to non 0 (mostly 1) and pgpool set the flag
for even none SELECTs. This resulted in failing to invalidate query
cache because if the flag is true, subsequent code in
pool_handle_query_cache() skips cache invalidation.  It was an
oversight in this commit (my fault):
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=2a99aa5d1910f1fd4855c8eb6751a26cbaa5e48d

To fix this change Execute() to check if the query is read only SELECT
before setting the flag.

Also add test to 006.memqcache.

Problem reported by and a test program provided by Achilleas Mantzios <a.mantzios at cloud.gatewaynet.com>.

Discussion: [pgpool-general: 9427] Clarification on query results cache visibility
https://www.pgpool.net/pipermail/pgpool-general/2025-April/009430.html

Backpatch-through: v4.2

Branch
------
V4_6_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=1dfacffedbbb82bc00765b4b5df5bee8b239b052

Modified Files
--------------
src/protocol/pool_proto_modules.c                  | 14 +++++---
src/test/regression/tests/006.memqcache/expected.5 | 37 ++++++++++++++++++++++
.../tests/006.memqcache/query_cache_bug5.data      | 37 ++++++++++++++++++++++
src/test/regression/tests/006.memqcache/test.sh    | 10 +++++-
4 files changed, 92 insertions(+), 6 deletions(-)



More information about the pgpool-committers mailing list