Re: persistent db connections/resiliency

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: persistent db connections/resiliency
Дата
Msg-id 7616.971130214@sss.pgh.pa.us
обсуждение исходный текст
Ответ на persistent db connections/resiliency  (Robert Boyd <rboyd@ivmg.net>)
Список pgsql-general
Robert Boyd <rboyd@ivmg.net> writes:
> Should I get connection status before every query, and if bad, attempt
> reconnect?

Waste of time, assuming you are thinking of PQstatus(); it just returns
a field from the PGconn struct showing the last known state.

I'd suggest that *upon error* you check to see if the error indicates
a dead connection, and attempt reconnect if so.  No need to expend
cycles in the main line of your app for this.

If you really want an end-to-end connectivity check, you can issue
an empty query string with PQexec; but I'd not recommend doing that
for every single query...

            regards, tom lane

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

Предыдущее
От: Erno Kuusela
Дата:
Сообщение: Change/convert encoding?
Следующее
От: "Serg King"
Дата:
Сообщение: NULL value in one argument will clear all arguments in server-side functions ( plpgsql ) to NULL?!