<div dir="ltr">Hi Tatsuo,<div>I just tried the patch on 3.6.4 and it works. Thanks! </div><div>When do you think this will become available in the yum repositories?</div><div>-AJ</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 26, 2017 at 1:32 PM, Tatsuo Ishii <span dir="ltr">&lt;<a href="mailto:ishii@sraoss.co.jp" target="_blank">ishii@sraoss.co.jp</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think I found the cause of the problem.<br>
It seems node.js sends a query in following pattern:<br>
<br>
Parse<br>
Bind<br>
Describe<br>
Execute<br>
Flush<br>
Sync<br>
<br>
The &quot;Flush&quot; message is actually unnecessary: it just requests backend<br>
(in this case Pgpool-II) to send any result pending in the<br>
backend. However, which will be accomplished by the subsequent &quot;Sync&quot;<br>
message. So the Flush message is completely redundant here.<br>
<br>
Anyway, the pattern is not supposed in Pgpool-II.<br>
Can you please try the attached fix?<br>
<span class=""><br>
Best regards,<br>
--<br>
Tatsuo Ishii<br>
SRA OSS, Inc. Japan<br>
English: <a href="http://www.sraoss.co.jp/index_en.php" rel="noreferrer" target="_blank">http://www.sraoss.co.jp/index_<wbr>en.php</a><br>
Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.<wbr>jp</a><br>
<br>
</span><span class="">&gt; Hi Tatsuo,<br>
&gt; Thanks for looking into it, I am just coping you and my team-mates instead<br>
&gt; of spamming the whole group.<br>
&gt;<br>
&gt; I have attached more details, hopefully this helps you. I have attached a<br>
</span>&gt; node.js script (*pgpool_test.js.txt, *I had to add a .txt extension because<br>
<span class="">&gt; gmail would not allow me to attach a file with a .js extension) which<br>
</span>&gt; creates a table* public.test *with just one column (id) and one row (id=1).<br>
<span class="">&gt; It then runs &quot;select  * from public.test where id=1&quot; twice using a<br>
&gt; non-parametrized query and then again twice using a parameterized query.<br>
&gt;<br>
</span>&gt;  As you can see in *output.log*, the table creation and the first two non<br>
<span class="">&gt; parametrized queries run fine. The first parameterized query also runs fine<br>
&gt; (because it wasn&#39;t cached). The second parametrized query never returns and<br>
&gt; node script just hangs.<br>
&gt;<br>
</span>&gt; I am also attaching the pgpool output log (*pgpool.log*) and the tcp packet<br>
&gt; capture (*dump.out*, viewable in wireshark) that captured all the tcp<br>
<span class="">&gt; traffic between the client and the machine running pgpool. Let me know if<br>
&gt; you need anything else.<br>
&gt;<br>
&gt; -AJ<br>
&gt;<br>
&gt; If you want to run the node.js script yourself, here are the instructions<br>
&gt; to do that (on a linux machine)<br>
&gt;<br>
</span>&gt;    - Install node (the instructions would be machine specific)<br>
&gt;    - npm install pg<br>
&gt;    - npm install seq<br>
&gt;    - PGPORT=&lt;PGPOOL_PORT&gt; PGDATABASE=&lt;DATABASE_NAME&gt; PGHOST=&lt;PH_HOST_NAME&gt;<br>
<div class="HOEnZb"><div class="h5">&gt;    PGUSER=&lt;PG_USERNAME&gt; node  pgpool_test.js<br>
&gt;<br>
&gt;<br>
&gt; On Fri, May 19, 2017 at 12:30 AM, Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp">ishii@sraoss.co.jp</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; &gt; Hi,<br>
&gt;&gt; &gt; I am having an issue with using parameterized queries with pgpool. My<br>
&gt;&gt; setup<br>
&gt;&gt; &gt; involves using node.js client with pgpool (3.6.4) and postgresl 9.6. I am<br>
&gt;&gt; &gt; using pgpool just for caching using shmem.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I have a simple example with the following query &quot;SELECT * FROM<br>
&gt;&gt; &gt; master.employer where employer_id=$1&quot;.  The query returns fine the first<br>
&gt;&gt; &gt; time and then it gets cached. When I run it again it hits the cache, but<br>
&gt;&gt; &gt; returns an empty resultset.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Let me know if I can provide with any other details. I have attached the<br>
&gt;&gt; &gt; entire pgpool log.<br>
&gt;&gt;<br>
&gt;&gt; In the log I see:<br>
&gt;&gt;<br>
&gt;&gt; 2017-05-18 21:13:30: pid 22781: DEBUG:  memcache: sending cached messages:<br>
&gt;&gt; &#39;D&#39; len: 4917<br>
&gt;&gt; 2017-05-18 21:13:30: pid 22781: DEBUG:  memcache: sending cached messages:<br>
&gt;&gt; &#39;C&#39; len: 13<br>
&gt;&gt;<br>
&gt;&gt; which means first Pgpool-II sends &#39;D&#39; (actual row data) in 4917 bytes<br>
&gt;&gt; then &#39;C&#39; (Indicating select command completed). This is perfectly sane<br>
&gt;&gt; from the protocol&#39;s point of view. So as far as the log says,<br>
&gt;&gt; Pgpool-II successfully returns cached data to client. So the remaining<br>
&gt;&gt; possibility is the returned data is broken. I don&#39;t what kind of debug<br>
&gt;&gt; method node.js has, but is it possible to capture/dump the packet data<br>
&gt;&gt; using wireshark?<br>
&gt;&gt;<br>
&gt;&gt; Best regards,<br>
&gt;&gt; --<br>
&gt;&gt; Tatsuo Ishii<br>
&gt;&gt; SRA OSS, Inc. Japan<br>
&gt;&gt; English: <a href="http://www.sraoss.co.jp/index_en.php" rel="noreferrer" target="_blank">http://www.sraoss.co.jp/index_<wbr>en.php</a><br>
&gt;&gt; Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.<wbr>jp</a><br>
&gt;&gt;<br>
</div></div><br>diff --git a/src/query_cache/pool_<wbr>memqcache.c b/src/query_cache/pool_<wbr>memqcache.c<br>
index fdef8c1..b8a5a5a 100644<br>
--- a/src/query_cache/pool_<wbr>memqcache.c<br>
+++ b/src/query_cache/pool_<wbr>memqcache.c<br>
@@ -645,43 +645,9 @@ POOL_STATUS pool_fetch_from_memory_cache(<wbr>POOL_CONNECTION *frontend,<br>
        pfree(qcache);<br>
<br>
        /*<br>
-        * If we are doing extended query, forward sync message from frontend to<br>
-        * backend. This is necessary to prevent receiving Sync message after<br>
-        * Sending Ready for query.<br>
+        * Send a &quot;READY FOR QUERY&quot; if not in extended query.<br>
         */<br>
-       if (pool_is_doing_extended_query_<wbr>message())<br>
-       {<br>
-               char kind;<br>
-               int32 len;<br>
-               POOL_SESSION_CONTEXT *session_context;<br>
-               POOL_CONNECTION *target_backend;<br>
-               char buf[5];<br>
-<br>
-               if (pool_flush(frontend))<br>
-                       return POOL_END;<br>
-               if (pool_read(frontend, &amp;kind, 1))<br>
-                       return POOL_END;<br>
-<br>
-               ereport(DEBUG2,<br>
-                               (errmsg(&quot;memcache: fetching from memory cache: expecting sync: kind &#39;%c&#39;&quot;, kind)));<br>
-               if (pool_read(frontend, &amp;len, sizeof(len)))<br>
-                       return POOL_END;<br>
-<br>
-               /* Forward &quot;Sync&quot; message to backend */<br>
-               session_context = pool_get_session_context(true)<wbr>;<br>
-               target_backend = CONNECTION(backend, session_context-&gt;load_balance_<wbr>node_id);<br>
-               pool_write(target_backend, &amp;kind, 1);<br>
-               pool_write_and_flush(target_<wbr>backend, &amp;len, sizeof(len));<br>
-<br>
-               /* Read and discard &quot;Ready for query&quot; message from backend */<br>
-               pool_read(target_backend, &amp;kind, 1);<br>
-               pool_read(target_backend, buf, sizeof(buf));<br>
-       }<br>
-<br>
-       /*<br>
-        * send a &quot;READY FOR QUERY&quot;<br>
-        */<br>
-       if (MAJOR(backend) == PROTO_MAJOR_V3)<br>
+       if (!pool_is_doing_extended_<wbr>query_message() &amp;&amp; MAJOR(backend) == PROTO_MAJOR_V3)<br>
        {<br>
                signed char state;<br>
<br>
@@ -691,10 +657,7 @@ POOL_STATUS pool_fetch_from_memory_cache(<wbr>POOL_CONNECTION *frontend,<br>
                state = MASTER(backend)-&gt;tstate;<br>
                send_message(frontend, &#39;Z&#39;, 5, (char *)&amp;state);<br>
        }<br>
-       else<br>
-       {<br>
-               pool_write(frontend, &quot;Z&quot;, 1);<br>
-       }<br>
+<br>
        if (pool_flush(frontend))<br>
        {<br>
                return POOL_END;<br>
<br></blockquote></div><br></div>