[pgpool-hackers: 3877] Re: [pgpool-committers: 7575] pgpool: Fix that query cache is not created in other than streaming and
Tatsuo Ishii
ishii at sraoss.co.jp
Mon Apr 5 13:08:18 JST 2021
I found a long standing bug with query cache and fixed it. Following
conditions are met, query cache is not created.
- extended query mode
- other than streaming replication or logical replication mode
- query is inside an explicit transaction
Please see the commit message below for more details.
> 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
> ------
> master
>
> Details
> -------
> https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=0ae9e440a004960c56108806202b68d6b399e40d
>
> 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-hackers
mailing list