[pgpool-committers: 9179] pgpool: Fix multiple query cache bug.

Tatsuo Ishii ishii at sraoss.co.jp
Sun Feb 5 21:21:21 JST 2023


Fix multiple query cache bug.

1) pool_add_item_shmem_cache() calls pool_init_cache_block() when
   there's no free cache item hash table entry. But this is
   unnecessary since pool_reuse_block() is already called from
   pool_add_item_shmem_cache(). This is actually harmless because the
   second pool_init_cache_block() call just set the same data as the
   first call of pool_init_cache_block(). It's just a waste of CPU
   cycle.

2) The cache blocks are supposed to be initialized while Pgpool-II
   starts up but actually not. Each cache block has the free space
   length in the block header after initialization. Since the free
   space length is not set, pool_get_block() fails to find a cache
   block which has enough free space, and it calls pool_reuse_block(),
   which is actually unnecessary (you will see something like
   "pool_reuse_block: blockid: 0" in pgpool log). Since
   pool_reuse_block() returns a free block anyway, this is just a
   waste of CPU cycle but better to fix.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-January/004259.html
Backpatch-through: 4.0

Branch
------
master

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

Modified Files
--------------
src/include/query_cache/pool_memqcache.h |  2 ++
src/main/pgpool_main.c                   |  4 +++-
src/query_cache/pool_memqcache.c         | 27 ++++++++++++++++++++-------
3 files changed, 25 insertions(+), 8 deletions(-)



More information about the pgpool-committers mailing list