New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
connection.closed attribute is not set properly on localconnections #196
Comments
Originally submitted by: Zaar Hai Formatting did not go well through web form. The reproduction is below. $ python
Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> conn = psycopg2.connect("dbname=tst host=/tmp")
>>> conn.closed
0
>>> # Issuse CTRL-Z
[1]+ Stopped python
$ service postgresql restart
* Restarting PostgreSQL 9.1 database server
...done.
$ fg
python
>>> cur = conn.cursor()
>>> cur.execute("SELECT 1")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
psycopg2.OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
>>> conn.closed # <------------ Should be greater then zero!
0
>>> psycopg2.__version__
'2.5.2 (dt dec pq3 ext)'
>>>
|
Yup, thank you for the report: i'd noticed something similar in #192. Thank you for the test case, I'll try to fix it. |
Originally submitted by: Zaar Hai BTW, to emphasize, that if one connects through TCP and not local socket, then |
Ugh, thank you for the clarification, I wouldn't have expected such a difference. |
Originally submitted by: Zaar Hai Yeah, I've spotted it while working on Momoko - dead connection detection stopped functioning when one connects through local socket. |
In debug mode, executing into a broken socket connection:
In a tcp connection instead:
so this should be the branch point: PQexec returning NULL vs. a "not ok" result. |
Originally submitted by: Zaar Hai Verified: works for me at https://github.com/dvarrazzo/psycopg.git#d1e1243ba851641feb2920148a44de3b92542997 Waiting for 2.5.3. |
Thank you for testing: I'll try to clear the issues with poll too and pack up the release within a few days. |
This happens for Socket connections, not for TCP ones, where a result containing an error is returned and correctly handled by pq_raise() Closes ticket psycopg#196 but not psycopg#192: poll() still doesn't change the connection closed.
This happens for Socket connections, not for TCP ones, where a result containing an error is returned and correctly handled by pq_raise() Closes ticket psycopg#196 but not psycopg#192: poll() still doesn't change the connection closed.
This happens for Socket connections, not for TCP ones, where a result containing an error is returned and correctly handled by pq_raise() Closes ticket psycopg#196 but not psycopg#192: poll() still doesn't change the connection closed. Conflicts: NEWS psycopg/pqpath.c
Originally submitted by: Psycopg website
Submitted by: haizaar
Scenario:
Expected result:
connection.closed attribute will should be greater then 0
Actual result:
connection.closed attribute is 0
Steps to reproduce:
Reproduced on:
python 2.7.5 / 2.6.8.
Postgresql 9.1 / 8.4
Ubuntu 13.10 64-bit / Centos 6.4 64-bit
The text was updated successfully, but these errors were encountered: