Skip to content

Commit f84c2a6

Browse files
committed
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.
1 parent 7008d9f commit f84c2a6

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

src/query_cache/pool_memqcache.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,9 +2126,7 @@ void
21262126
pool_clear_memory_cache(void)
21272127
{
21282128
size_t size;
2129-
pool_sigset_t oldmask;
21302129

2131-
POOL_SETMASK2(&BlockSig, &oldmask);
21322130
pool_shmem_lock(POOL_MEMQ_EXCLUSIVE_LOCK);
21332131

21342132
PG_TRY();
@@ -2148,13 +2146,11 @@ pool_clear_memory_cache(void)
21482146
PG_CATCH();
21492147
{
21502148
pool_shmem_unlock();
2151-
POOL_SETMASK(&oldmask);
21522149
PG_RE_THROW();
21532150
}
21542151
PG_END_TRY();
21552152

21562153
pool_shmem_unlock();
2157-
POOL_SETMASK(&oldmask);
21582154
}
21592155

21602156
#ifdef USE_MEMCACHED

src/test/regression/tests/006.memqcache/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ EOF
482482
exit 1
483483
fi
484484
# make sure query cache has gone
485+
$PSQL -t -c "SELECT 1" test # this query processes query cache invalidation request
485486
res1=`$PSQL -t -c "/*FORCE QUERY CACHE*/SELECT current_timestamp" test`
486487
if [ "$res1" = "$res2" ];then
487488
echo "query cache was not invalidated"

0 commit comments

Comments
 (0)