[pgpool-committers: 7574] pgpool: Fix that query cache is not created in other than streaming and

Tatsuo Ishii ishii at sraoss.co.jp
Mon Apr 5 11:44:02 JST 2021


Fix that query cache is not created in other than streaming and logical replication mode.

We used to create query cache in ReadyForQuery() in extended query
mode in other than streaming and logical replication mode. However if
following message sequence is sent from frontend, the query cache was
never created because pool_is_cache_safe() returns false in
pool_handle_query_cache(). Why? Because pool_is_cache_safe() examines
the current query context, and the current query context is for "END"
message.

'P'     ""      "BEGIN" 0
'B'     ""      ""      0       0       0
'E'     ""      0
'P'     "S1"    "SELECT 1"      0
'B'     "S1"    "S1"    0       0       0
'E'     "S1"    0
'P'     ""      "END"   0
'B'     ""      ""      0       0       0
'E'     ""      0
'S'
'Y'
'X'

So this commit changes CommandComplete() so that
pool_handle_query_cache() gets called in not only streaming and
logical replication mode. pool_handle_query_cache() will create a
temporary query cache and it will be processed when next time
ReadyForQuery() is called for an END message.

I found the bug while taking care of:
https://www.pgpool.net/mantisbt/view.php?id=700

Note that if the transaction is ended by a simple query message "END",
the bug does not appear because extended query SELECT messages will be
followed by a SYNC message, which will produce a Ready for query
message, and ReadyForQuery() will happily register query cache since
this time pool_is_cache_safe() returns true.

I think this is a long standing bug. The reason why this was not found
earlier is, despite the similar message sequence is created by the JDBC
driver, CommandComplete() already handles in the way described above.

Branch
------
V4_2_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=7d54c1b53cee3950e8ad1ebcda85b9a0acf405e8

Modified Files
--------------
src/protocol/CommandComplete.c    | 10 +++++-----
src/protocol/pool_proto_modules.c |  4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)



More information about the pgpool-committers mailing list