[pgpool-committers: 10278] pgpool: Fix query cache bug in streaming replication mode.

Tatsuo Ishii ishii at postgresql.org
Thu Dec 5 13:45:20 JST 2024


Fix query cache bug in streaming replication mode.

When query cache is enabled and an execute message is sent from
frontend, pgpool injects query cache data into backend message buffer
if query cache data is available. inject_cached_message() is
responsible for the task. But it had an oversight if the message
stream from frontend includes more than one sets of bind or describe
message before a sync message. It tried to determine the frontend
message end by finding a bind complete or a row description message
from backend. But in the case, it is possible that these messages do
not indicate the message stream end because there are one more bind
complete or row description message. As a result the cached message is
inserted at inappropriate positron and pgpool mistakenly raised "kind
mismatch" error.

This commit changes the algorithm to detect the message stream end:
compare the number of messages from backend with the pending message
queue length. When a message is read from backend, the counter for the
number of message is counted up if the message is one of parse
complete, bind complete, close complete, command compete, portal
suspended or row description. For other message type the counter is
not counted up. If the counter reaches to the pending message queue
length, we are at the end of message stream and inject the cahced
messages.

Test cases for 006.memqcache are added.

Backpatch-through: v4.2.

Branch
------
V4_2_STABLE

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

Modified Files
--------------
src/query_cache/pool_memqcache.c                   | 58 ++++++++++++++++++----
src/test/regression/tests/006.memqcache/expected.1 | 30 +++++++++++
src/test/regression/tests/006.memqcache/expected.2 | 25 ++++++++++
src/test/regression/tests/006.memqcache/expected.3 | 32 ++++++++++++
.../tests/006.memqcache/query_cache_bug1.data      | 21 ++++++++
.../tests/006.memqcache/query_cache_bug2.data      | 23 +++++++++
.../tests/006.memqcache/query_cache_bug3.data      | 21 ++++++++
src/test/regression/tests/006.memqcache/test.sh    | 52 +++++++++++++++++++
8 files changed, 252 insertions(+), 10 deletions(-)



More information about the pgpool-committers mailing list