Fix queries hanging in parse_before_bind with extended protocol and replication ...
authorTatsuo Ishii <ishii@postgresql.org>
Thu, 18 Jan 2018 01:37:23 +0000 (10:37 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Thu, 18 Jan 2018 01:44:22 +0000 (10:44 +0900)
In case the client sends a BIND message for a query
that has not yet been parsed by the executing node,
the PARSE will be executed before attempting to BIND
the parameters.

However, during the execution of the PARSE, the session
context is not set to in_progress, which leads to wrong
backend validity tests in read_kind_from_backend which
in turn makes the process wait on a backend which is not
going to send anything.

Fixes bug #377.

Bug report, analysis and fix by Ancoron Luciferis.

src/protocol/pool_proto_modules.c

index 9d276e7f8117b8138a2a4642f00e0ae311b41e87..35b0edec58872af3d24e13a653f04bdf51f27a44 100644 (file)
@@ -1170,8 +1170,12 @@ POOL_STATUS Bind(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
                pool_where_to_send(query_context, query_context->original_query,
                                                   query_context->parse_tree);
 
+               pool_set_query_in_progress();
                if (parse_before_bind(frontend, backend, parse_msg) != POOL_CONTINUE)
+               {
+                       pool_unset_query_in_progress();
                        return POOL_END;
+               }
        }
 
        /*