[pgpool-committers: 7584] pgpool: Fix pgpool crash when query cache enabled.
Tatsuo Ishii
ishii at sraoss.co.jp
Fri Apr 9 20:45:25 JST 2021
Fix pgpool crash when query cache enabled.
Pgpool-II crashed upon receiving CloseComplete.
This only happened in other than streaming and logical replication mode.
The minimum test case is as follows:
'P' "S1" "SELECT 1" 0
'B' "P1" "S1" 0 0 0
'E' "P1" 0
'C' 'P' "P1"
'B' "P2" "S1" 0 0 0
'E' "P2" 0
'C' 'P' "P2"
'S'
'Y'
'X'
A query statement S1 is bound to portal P1 and P1 is closed. When
CommandComplete message arrives, CloseComplete() discard temp query
cache buffer corresponding to the query context. Unfortunately it
forgot to set NULL to query_context->temp_cache. So whnen next time
other portal P2 which was also bound to S1 is closed, CloseComplete()
tries to free memory which was already freed by previous
CloseComplete. This leads to a segfault.
Fix is set NULL to query_context->temp_cache when the CloseComplete()
is called.
The reason why in streaming and logical replication this does occur
is, unlike other mode, in these mode query_context->temp_cache is
already freed and set to NULL when CommandComplete arrives.
Also new regression test
074.bug700_memqcache_bug_segfault_at_close_complete is added.
Per bug 700.
Branch
------
V4_0_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=63c360d6961a8f0a772fc994f8a774c7ec42b3a6
Modified Files
--------------
src/protocol/pool_proto_modules.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
More information about the pgpool-committers
mailing list