<div dir="ltr">Hi<div><br></div><div>After commenting out <span style="font-size:12.7272720336914px;font-family:&#39;courier new&#39;,monospace">xm.append(element.</span><span style="font-size:12.7272720336914px;font-family:&#39;courier new&#39;,monospace">ClosePortal(x))</span> I can successfully execute the test case.</div><div>can you share the pgpool-II log when this this error is thrown.</div><div><br></div><div>--Usama</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 30, 2014 at 10:02 AM, Сергей Мелехин <span dir="ltr">&lt;<a href="mailto:cpro29a@gmail.com" target="_blank">cpro29a@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello!<div>Thank you for replying!</div><div>I tried to comment out <font face="courier new, monospace">xm.append(element.ClosePortal(x))</font> in  (postgresql/protocol/client3.py line 364) but still getting random errors</div><div><br></div><div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error] 2014-09-30 04:57:31,067 ERROR [root][MainThread] \xd0\x98\xd1\x81\xd0\xba\xd0\xbb\xd1\x8e\xd1\x87\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb5 \xd0\xb2 \xd1\x84\xd1\x83\xd0\xbd\xd0\xba\xd1\x86\xd0\xb8\xd0\xb8 kbsite.users.getUser(&lt;kbsite.users.Users object at 0x7f35516e0160&gt;,5):</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error] Traceback (most recent call last):</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]   File &quot;/var/www/.ve/lib/python3.4/site-packages/sitelib-0.3.33-py3.4.egg/sitelib/tools/log.py&quot;, line 43, in inner</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]     return f( *args, **kwargs )</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]   File &quot;/var/www/.ve/lib/python3.4/site-packages/kbsite-0.2-py3.4.egg/kbsite/users.py&quot;, line 78, in getUser</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]     res = self.db.get_list(sql, [userId], limit=1)</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]   File &quot;/var/www/.ve/lib/python3.4/site-packages/sitelib-0.3.33-py3.4.egg/sitelib/tools/db/db.py&quot;, line 204, in get_list</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]     return self.query(sql, *params, limit=None if limit == &#39;all&#39; else int(limit), offset=offset)</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]   File &quot;/var/www/.ve/lib/python3.4/site-packages/sitelib-0.3.33-py3.4.egg/sitelib/tools/db/db.py&quot;, line 160, in query</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]     result = self._connection.query(sql, *args)</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]   File &quot;/var/www/.ve/lib/python3.4/site-packages/py_postgresql-1.1.2.pgpool-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 1231, in __call__</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]     return self._prepare(query)(*parameters)</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]   File &quot;/var/www/.ve/lib/python3.4/site-packages/py_postgresql-1.1.2.pgpool-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 2326, in prepare</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]     ps._fini()</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]   File &quot;/var/www/.ve/lib/python3.4/site-packages/py_postgresql-1.1.2.pgpool-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 1518, in _fini</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error]     (*head, argtypes, tupdesc, last) = self._xact.messages_received()</font></div><div><font face="courier new, monospace">[Tue Sep 30 04:57:31 2014] [error] ValueError: need more than 0 values to unpack</font></div></div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div>С Уважением, Сергей Мелехин.</div><div><div class="h5">
<br><div class="gmail_quote">2014-09-30 5:55 GMT+11:00 Muhammad Usama <span dir="ltr">&lt;<a href="mailto:m.usama@gmail.com" target="_blank">m.usama@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi<br><br>I have applied your purposed patchs after commenting out CloseStatement on line 1490 in postgresql/driver/pq3.py as suggested by you but still gets the same error <font face="courier new, monospace">ValueError: need more than 0 values to unpack,</font> when I execute your test case with pgpool-II.<br><br>I think the real problem is py-postgresql is not properly handling the close cursor scenario. <i>It wrongly issues the ClosePortal packet to the server for closing the opened cursor</i>. which is the cause of real problem. The fact that the test case works fine with bare PostgreSQL server without involvement of pgpool-II is because of a reason that PostgreSQL ignores the Close Portal packets for non existing portals. and when py-postgresql issues the close portal command with cursor name, that command gets silently ignored by postgres server and test case reports success.<div><br>But pgpool-II does not ignores the close portal for non existing portals and throws an error. Same reason we need to comment out CloseStatement in postgresql/driver/pq3.py to get pass the connecting phase with pgpool-II.<br><br></div><div>So apparently the solution for the problem is to fix the close cursor message in py-postgresql. I have tried this by commenting out the code used by py-postgresql to close cursor (<b>postgresql/protocol/client3.py line 364</b>) and the test case works fine after that.<br><br>Regards<br>Usama<br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Mon, Sep 22, 2014 at 10:27 AM, Сергей Мелехин <span dir="ltr">&lt;<a href="mailto:cpro29a@gmail.com" target="_blank">cpro29a@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div>Hello!</div><div><br></div><div>We are experiencing random failures when calling Connection.proc() with set returning functions through pgpool2.<br>I use py-postgresql-1.1.0 with commented out CloseStatement in line 1490 in postgresql/driver/pq3.py, to use it with pgpool2 (3.1.3 and 3.3.2) and postgresql 9.3.5.<br>And it looks like, that there are protocol errors.<br><br>Here is code that fails:<br><br><font face="courier new, monospace">import postgresql<br> <br>URL = &quot;pq://hr:hr@localhost:5434/hr&quot; //using pgpool2 (3.3.2)<br> <br>def main():<br>    db = postgresql.open(URL)<br>    db.execute(&quot;&quot;&quot;<br>        CREATE OR REPLACE FUNCTION foo()<br>          RETURNS SETOF boolean AS<br>        $BODY$<br>           select true;<br>        $BODY$<br>          LANGUAGE sql VOLATILE<br>          COST 100<br>          ROWS 1000;<br>        ALTER FUNCTION foo() OWNER TO hr;<br> <br>    &quot;&quot;&quot;)<br>    # db.query(&quot;select foo()&quot;) # works<br>    # v = db.proc(&quot;foo()&quot;)() #works<br>    db.proc(&quot;foo()&quot;)() # does not work<br> <br>    for i in range(200):<br>        db.query(&quot;select 1&quot;) //error comes here<br> <br> <br>if __name__ == &quot;__main__&quot;:<br>    main()</font><br><br> <br>And I get one of two errors:<br><br><font face="courier new, monospace"> Traceback (most recent call last):<br>  File &quot;/home/sergey/projects/emply/sitelib/sitelib/tests/error.py&quot;, line 28, in &lt;module&gt;<br>    main()<br>  File &quot;/home/sergey/projects/emply/sitelib/sitelib/tests/error.py&quot;, line 24, in main<br>    db.query(&quot;select 1&quot;)<br>  File &quot;/home/sergey/projects/emply/.venv/sitelib/lib/python3.4/site-packages/py_postgresql-1.1.0-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 1233, in __call__<br>    return self._prepare(query)(*parameters)<br>  File &quot;/home/sergey/projects/emply/.venv/sitelib/lib/python3.4/site-packages/py_postgresql-1.1.0-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 2329, in prepare<br>    ps._fini()<br>  File &quot;/home/sergey/projects/emply/.venv/sitelib/lib/python3.4/site-packages/py_postgresql-1.1.0-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 1521, in _fini<br>    (*head, argtypes, tupdesc, last) = self._xact.messages_received()<br>ValueError: need more than 0 values to unpack</font><br> <br>Or:<br><br><font face="courier new, monospace">Traceback (most recent call last):<br>  File &quot;/home/sergey/projects/emply/sitelib/sitelib/tests/error.py&quot;, line 28, in &lt;module&gt;<br>    main()<br>  File &quot;/home/sergey/projects/emply/sitelib/sitelib/tests/error.py&quot;, line 24, in main<br>    db.query(&quot;select 1&quot;)<br>  File &quot;/home/sergey/projects/emply/.venv/sitelib/lib/python3.4/site-packages/py_postgresql-1.1.0-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 1233, in __call__<br>    return self._prepare(query)(*parameters)<br>  File &quot;/home/sergey/projects/emply/.venv/sitelib/lib/python3.4/site-packages/py_postgresql-1.1.0-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 1573, in __call__<br>    c = SingleXactFetch(self, parameters)<br>  File &quot;/home/sergey/projects/emply/.venv/sitelib/lib/python3.4/site-packages/py_postgresql-1.1.0-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 868, in __init__<br>    Output.__init__(self, &#39;&#39;)<br>  File &quot;/home/sergey/projects/emply/.venv/sitelib/lib/python3.4/site-packages/py_postgresql-1.1.0-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 655, in __init__<br>    self._init()<br>  File &quot;/home/sergey/projects/emply/.venv/sitelib/lib/python3.4/site-packages/py_postgresql-1.1.0-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 885, in _init<br>    STEP()<br>  File &quot;/home/sergey/projects/emply/.venv/sitelib/lib/python3.4/site-packages/py_postgresql-1.1.0-py3.4-linux-x86_64.egg/postgresql/driver/pq3.py&quot;, line 2615, in _pq_step<br>    pq.step()<br>  File &quot;/home/sergey/projects/emply/.venv/sitelib/lib/python3.4/site-packages/py_postgresql-1.1.0-py3.4-linux-x86_64.egg/postgresql/protocol/client3.py&quot;, line 420, in step<br>    &quot;unexpected PQ transaction state: &quot; + repr(dir)<br>RuntimeError: unexpected PQ transaction state: None</font><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.7272720336914px"><font face="courier new, monospace"><br></font></div>We got rid of errors, by making some minor changes in pq3.py:<div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.7272720336914px"><br></div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.7272720336914px"><a href="https://github.com/C-Pro/fe/commit/26a360be216975229215d458b27c644e1bd1893b" target="_blank">https://github.com/C-Pro/fe/commit/26a360be216975229215d458b27c644e1bd1893b</a><br></div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.7272720336914px"><a href="https://github.com/C-Pro/fe/commit/a69da2b05048e7d801cece6a75e4c80a53cc27d4" target="_blank">https://github.com/C-Pro/fe/commit/a69da2b05048e7d801cece6a75e4c80a53cc27d4</a><br></div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.7272720336914px"><br></div>and<div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.7272720336914px"><br></div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.7272720336914px"><a href="https://github.com/C-Pro/fe/commit/adb4d98240eeaf250543d2350a5d3c71fb58c5f8" target="_blank">https://github.com/C-Pro/fe/commit/adb4d98240eeaf250543d2350a5d3c71fb58c5f8</a><br></div>to return list, and changed version to automatically pull new version as an app dependency on deployment.<br><br>All existing tests pass.<br><br>It would be perfect if you could review changes, because I think tere is misunderstanding of extended protocol between pgpool2 and py-postgresql.<br><br>With best regards, Sergey Melekhin</div><div><br></div>
</div>
<br></div></div>_______________________________________________<br>
pgpool-general mailing list<br>
<a href="mailto:pgpool-general@pgpool.net" target="_blank">pgpool-general@pgpool.net</a><br>
<a href="http://www.pgpool.net/mailman/listinfo/pgpool-general" target="_blank">http://www.pgpool.net/mailman/listinfo/pgpool-general</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div>