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:28:34 +0000 (11:28 +0900)
commita091bcb4dece8b09089689a8fa775136f61e75df
treeb5e6a481adf216cc9de857b71eae04b7688d1f78
parent7ff642f2ae352463bb86f2f8b1e346044325fcfc
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