pgpool2.git / summary / log / commit / refs
commit a5fdf78e6e86c5a8a1d4ce5b1eb273a59f5ecfb9
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Wed Apr 13 07:56:57 2016 +0000
Fix extended protocol hang with empty query
The fixes related to extended protocol cases in 3.5.1 broke the case
of empty query. In this case backend replies with "empty query
response" which is same meaning as a command complete message. Problem
is, when empty query response is received, pgpool does not reset the
query in progress flag thus keeps on waiting for backend. However,
backend will not send the ready for query message until it receives a
sync message. Fix is, resetting the in progress flag after receiving
the empty query response and reads from frontend expecting it sends a
sync message.
Per bug 190.
src/protocol/pool_process_query.c | 11 ++++++-----
src/protocol/pool_proto_modules.c | 8 +++++++-
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/protocol/pool_process_query.c b/src/protocol/pool_process_query.c
index 934cc3379..19f6b8258 100644
--- a/src/protocol/pool_process_query.c
+++ b/src/protocol/pool_process_query.c
@@ -745,7 +745,7 @@ POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION *frontend,
/*
* If we received a notification message in master/slave mode,
* other backends will not receive the message.
- * So we should skip other nodes otherwise we will hung in pool_read.
+ * So we should skip other nodes otherwise we will hang in pool_read.
*/
if (!MASTER_SLAVE || kind != 'A')
{
@@ -3233,15 +3233,16 @@ void read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
if (MASTER_SLAVE)
{
- read_kind_from_one_backend(frontend, backend, (char *)&kind, MASTER_NODE_ID);
-
- ereport(DEBUG1,
+ ereport(DEBUG1,
(errmsg("reading backend data packet kind"),
errdetail("master node id: %d", MASTER_NODE_ID)));
+
+ read_kind_from_one_backend(frontend, backend, (char *)&kind, MASTER_NODE_ID);
+
/*
* If we received a notification message in master/slave mode,
* other backends will not receive the message.
- * So we should skip other nodes otherwise we will hung in pool_read.
+ * So we should skip other nodes otherwise we will hang in pool_read.
*/
if (kind == 'A')
{
diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c
index 242799ef8..d937387cf 100644
--- a/src/protocol/pool_proto_modules.c
+++ b/src/protocol/pool_proto_modules.c
@@ -2490,7 +2490,13 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
case 'I': /* EmptyQueryResponse */
status = SimpleForwardToFrontend(kind, frontend, backend);
- if ((REPLICATION || RAW_MODE) && pool_is_doing_extended_query_message())
+ /* Empty query response message should be treated same as
+ * Command complete message. When we receive the Command
+ * complete message, we unset the query in progress flag if
+ * operated in streaming replication mode. So we unset the
+ * flag as well. See bug 190 for more details.
+ */
+ if (pool_is_doing_extended_query_message())
pool_unset_query_in_progress();
break;
[parent: 0e01d3238bfb]