[pgpool-committers: 3044] pgpool: Fix query stack problems in extended protocol case.

Tatsuo Ishii ishii at postgresql.org
Thu Mar 3 15:39:33 JST 2016


Fix query stack problems in extended protocol case.

This fix is for both bug167 and 168.

The bug 167 iss caused by following message sequence:

13:38:24.947 (1) FE=> Parse(stmt=null,query="BEGIN",oids={})
13:38:24.947 (1) FE=> Bind(stmt=null,portal=null)
13:38:24.947 (1) FE=> Execute(portal=null,limit=0)
13:38:24.948 (1) FE=> Parse(stmt=null,query="SELECT t.typname,t.oid FROM pg_catalog.pg_type t JOIN pg_catalog.pg_namespace n ON (t.typnamespace = n.oid) WHERE n.nspname != 'pg_toast'",oids={})
13:38:24.948 (1) FE=> Bind(stmt=null,portal=null)
13:38:24.948 (1) FE=> Describe(portal=null)
13:38:24.948 (1) FE=> Execute(portal=null,limit=0)
13:38:24.948 (1) FE=> Sync

As you can see before sync for "BEGIN" is issued next parse message
arrives. Then sync is arrived after the second query. Since the query
in progress flag is unset, pgpool-II tries to read data from backend 0
(this is ok because the messages have been sent to it) and backend 1
which will block since no messages are sent in this case (load balance
node = 0).

Fix is, decide which node to read by looking at sync map. For this
purpose, pool_read_message_length(), ReadyForQuery(),
SimpleForwardToFrontend(), read_kind_from_backend() are modified to
use new function pool_use_sync_map().

Another important fix is around line 211 of
pool_process_query(). Before we call ProcessBackendResponse() only
when query is in progress. This is wrong since there might be a
pending data in the backend cache and we need to process it. This
could happen if do_query() stacks up pending data. Otherwise pgpool-II
repeats to visit the line infinitely. I suspect this is the cause
reported in pgpool-hackers: 1432. New function
is_backend_cache_empty() is added to check if there's pending data in
the backend cache in ProcessBackendResponse().

Branch
------
master

Details
-------
http://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=bb295a22ad47001758b0b38968f53c776f439f2f

Modified Files
--------------
src/auth/pool_auth.c                       | 14 ++++++-
src/context/pool_query_context.c           | 10 ++---
src/context/pool_session_context.c         | 28 +++++++++++++
src/include/context/pool_session_context.h | 12 +++++-
src/include/pool.h                         |  2 +
src/protocol/pool_process_query.c          | 63 ++++++++++++++++++++++--------
src/protocol/pool_proto_modules.c          | 20 +++++++++-
7 files changed, 123 insertions(+), 26 deletions(-)



More information about the pgpool-committers mailing list