[pgpool-committers: 773] pgpool: Fix LISTEN/NOTIFY handling bugs reported in bug #45.
ishii at postgresql.org
Wed Jan 16 13:24:39 JST 2013
Fix LISTEN/NOTIFY handling bugs reported in bug #45.
1) In streaming replication mode:
Session 1: LISTEN aaa;
Session 2: NOTIFY aaa;
Session 1: LISTEN aaa; --- hangs
(If LISTEN and NOTIFY are issued in a same session, it works fine.)
We assume that packets come from all nodes. However in streaming
replication mode, notification message only comes from primary
node and we should avoid reading from standby nodes.
2) In streaming replication mode: If primary node is not node 0, it
hangs like #1 even if fix applies. This is because MASTER_NODE_ID
macro (actually pool_virtual_master_db_node_id() always returns
REAL_MASTER_NODE_ID, which is node 0 (if it is alive). The function
should return PRIMARY_NODE_ID in master/slave mode.
3) In replication mode, LISTEN/NOTIFY simply does not work. In the
mode, NOTIFY is sent to all backends. However the order of arrival of
'Notification response' is not necessarily the master first and then
slaves. So if it arrives slave first, we should try to read from
master, rather than just discard it. Fixed in pool_process_query().
4) In replication mode, if LISTEN and NOTIFY are issued in a same
session, the session is disconnected because do_command() may receive
other than 'N', 'E', 'S' and 'C'. The solution is, put 'A' packet on a
stack and pop out when it is convenient. For this purpose, new
functions pool_push(), pool_pop() and pool_stacklen() are added.
Considering the size of the patch, I do not back patch to 3.1 or
before(so far, we have not heard any complaints on 3.1 or before).
pool.h | 3 +
pool_process_query.c | 155 +++++++++++++++++++++++++++++++++++++++-----------
pool_query_context.c | 8 ++-
pool_stream.c | 60 +++++++++++++++++++
pool_stream.h | 5 +-
5 files changed, 195 insertions(+), 36 deletions(-)
More information about the pgpool-committers