From: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | libpq connection status and closed fd |
Date: | 2014-09-22 06:42:01 |
Message-ID: | CA+mi_8YF2XRJKKkiaN_D1h4f=5wGqL-0h43qdeA0wU9CHsNVtA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello,
a psycopg user is reporting [1] that the library is not marking the
connection as closed and/or bad after certain errors, such as a
connection timeout. He is emulating the error by closing the
connection fd (I don't know if the two conditions result in the same
effect, but I'll stick to this hypothesis for now).
[1] https://github.com/psycopg/psycopg2/issues/263
Testing with a short C program [2] it seems that indeed, after closing
the fd and causing an error in `PQconsumeInput`, the connection is
deemed in good state by `PQstatus`. A similar test gives the same
result after `PQexec` is attempted on a connection whose fd is closed
(tests performed with PostgreSQL 9.3.5).
[2] https://gist.github.com/dvarrazzo/065f343c95f8ea67cf8f
Is this intentional? Is there a better way to check for a broken connection?
If we mark the connection as closed every time `PQconsumeInput`
returns 0 (or `PQexec` returns null, which are the two code paths
affecting psycopg) would it be too aggressive and cause false
positives?
Thank you very much.
-- Daniele
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2014-09-22 06:46:14 | Documentation fix for pg_recvlogical's --create mode |
Previous Message | Michael Paquier | 2014-09-22 06:40:41 | Re: pg_receivexlog and replication slots |