From f84c2a6345367bd6aee05b87dd5e573be724f715 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Thu, 17 Oct 2024 13:59:17 +0900 Subject: [PATCH] Fix bug in pcp_invalidate_query_cache. Buildfarm reported 006.memqcache failure. This was caused by a mistake in the test script (test.sh). It executes pcp_invalidate_query_cache then compares the results of a query calling current_timestamp which is already in query cache (using /*FORCE QUERY CACHE*/ comment). Since pcp_invalidate_query_cache just places an invalidation request and next query processes it, comparing the result right after execution of "SELECT current_timestamp" with the previous cached result indeed returns an equality and the test failed. To fix this, after pcp_invalidate_query_cache, executes a different query. Also I found the test not only fails, but sometimes causes timeout at my local environment. Inspecting the remaining child process showed that it is likely the SIGINT handler was not executed (variable exit_request was not set). I suspect this is because pool_clear_memory_cache(), which is responsible for actually clearing the query cache, blocks all signal including SIGINT. I think this is the reason why the signal handler for SIGINT is not executed. Since pool_clear_memory_cache() already uses pool_shmem_lock() to protect the operation on query cache, the signal blocking is not necessary. In this commit I just removed calls to POOL_SETMASK2 and POOL_SETMASK. --- src/query_cache/pool_memqcache.c | 4 ---- src/test/regression/tests/006.memqcache/test.sh | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/query_cache/pool_memqcache.c b/src/query_cache/pool_memqcache.c index de50729d1..4c55f0fc4 100644 --- a/src/query_cache/pool_memqcache.c +++ b/src/query_cache/pool_memqcache.c @@ -2126,9 +2126,7 @@ void pool_clear_memory_cache(void) { size_t size; - pool_sigset_t oldmask; - POOL_SETMASK2(&BlockSig, &oldmask); pool_shmem_lock(POOL_MEMQ_EXCLUSIVE_LOCK); PG_TRY(); @@ -2148,13 +2146,11 @@ pool_clear_memory_cache(void) PG_CATCH(); { pool_shmem_unlock(); - POOL_SETMASK(&oldmask); PG_RE_THROW(); } PG_END_TRY(); pool_shmem_unlock(); - POOL_SETMASK(&oldmask); } #ifdef USE_MEMCACHED diff --git a/src/test/regression/tests/006.memqcache/test.sh b/src/test/regression/tests/006.memqcache/test.sh index e915d8c5d..4b218e197 100755 --- a/src/test/regression/tests/006.memqcache/test.sh +++ b/src/test/regression/tests/006.memqcache/test.sh @@ -482,6 +482,7 @@ EOF exit 1 fi # make sure query cache has gone + $PSQL -t -c "SELECT 1" test # this query processes query cache invalidation request res1=`$PSQL -t -c "/*FORCE QUERY CACHE*/SELECT current_timestamp" test` if [ "$res1" = "$res2" ];then echo "query cache was not invalidated" -- 2.39.5