libpq connection status and closed fd

Поиск
Список
Период
Сортировка
От Daniele Varrazzo
Тема libpq connection status and closed fd
Дата
Msg-id CA+mi_8YF2XRJKKkiaN_D1h4f=5wGqL-0h43qdeA0wU9CHsNVtA@mail.gmail.com
обсуждение исходный текст
Ответы Re: libpq connection status and closed fd  (Dmitriy Igrishin <dmitigr@gmail.com>)
Re: libpq connection status and closed fd  (Andres Freund <andres@2ndquadrant.com>)
Re: libpq connection status and closed fd  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: pg_receivexlog and replication slots
Следующее
От: Michael Paquier
Дата:
Сообщение: Documentation fix for pg_recvlogical's --create mode