Prevent query cache update under shared lock.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Wed, 14 Jun 2023 02:17:38 +0000 (11:17 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Wed, 14 Jun 2023 02:17:38 +0000 (11:17 +0900)
commita16d34b81a4e772e16185028f8b89604a29f0412
treebaa89f9e49e32cd1bb4fad0a6878219f9162e281
parent36d695d8ce875c454610159d89b899ab2c076603
Prevent query cache update under shared lock.

In https://www.pgpool.net/mantisbt/view.php?id=795 it was pointed out
that expired query cache entry can be modified under shared lock. This
could cause shared memory corruption used by query cache. In order to
fix this, we temporarily release the shared lock and then acquire an
exclusive lock before modifying the cache entry. This could create a
window and we need to get the cache entry meta data again to make sure
that the meta data has not been modified by someone else.

Back-patch to V4.4 stable where shared locking for query cache was
introduced.
src/query_cache/pool_memqcache.c