[pgpool-committers: 4079] pgpool: Fix bug with sending bind message to wrong target node.
ishii at postgresql.org
Wed Jun 7 14:16:38 JST 2017
Fix bug with sending bind message to wrong target node.
When a close portal message received, Pgpool-II forwards it to both
primary and load balance node in streaming replication mode. Later on
a close complete message returned from backend, and
read_kind_from_backend gets called, then it calls
pool_pending_message_query_context_dest_set, which rewrites
where_to_send map in the current query context accordingly. If a bind
message using the same query is received, it will be forwarded to both
primary and load balance node because the where_to_send map was
rewritten so. Unfortunately, the prepared statement might not exist on
primary node, if the query was parsed only on the load balance
node. So we get an error.
Fix is, restoring the where_to_send map after processing the close
complete message. For this sake, where_to_send map back up area is
added to session context. Also new flag need_to_restore_where_to_send
is added. Those new data is handled inside
pool_pending_message_query_context_dest_set. The where_to_send map is
restored in pool_unset_query_in_progress. There were several places
which do not call pool_unset_query_in_progress. They are also fixed to
Per bug #314.
To reproduce the problem, following pgproto data can be used. Also you
need to set the weight parameter on primary to 0 and standby to 1 to reliably
reproduce the problem.
'P' "S_1" "SELECT 1" 0
'B' "C_1" "S_1" 0 0 0
'E' "C_1" 0
'C' 'P' "C_1"
'B' "C_2" "S_1" 0 0 0
'E' "C_2" 0
src/context/pool_session_context.c | 18 +++++++++++++++++-
src/include/context/pool_session_context.h | 8 ++++++++
src/protocol/pool_proto_modules.c | 22 ++++++++++++++++++++++
3 files changed, 47 insertions(+), 1 deletion(-)
More information about the pgpool-committers