Re: Backend freezes at "idle in transaction" while using libpq PQexec (PostgreSQL version 9.1.2)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Backend freezes at "idle in transaction" while using libpq PQexec (PostgreSQL version 9.1.2)
Дата
Msg-id 20072.1342888136@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Backend freezes at "idle in transaction" while using libpq PQexec (PostgreSQL version 9.1.2)  (Prima Chairunnanda <prima.ch@gmail.com>)
Список pgsql-novice
Prima Chairunnanda <prima.ch@gmail.com> writes:
> I have a problem with using libpq to execute query. I am using it in a
> program which coordinates multiple queries, so the program will open
> several PGconn connections. However, intermittently, some sessions just
> appear to "freeze", and the back-end status is "idle in transaction
> (aborted)".

> Upon closer inspection with gdb, I found that both the front-end and
> back-end are waiting to receive message!

I would say the odds are at least ten-to-one that this is the
consequence of different threads trying to manipulate the same PGconn
object concurrently.  libpq itself is not multi-threaded and does not
provide any protection against such mistakes.  In a multi-threaded
environment it's frequently a good idea to wrap a PGconn in a larger
object that includes a mutex, so that you can prevent this type of
problem via locking.

            regards, tom lane

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

Предыдущее
От: Prima Chairunnanda
Дата:
Сообщение: Backend freezes at "idle in transaction" while using libpq PQexec (PostgreSQL version 9.1.2)
Следующее
От: David Raznick
Дата:
Сообщение: copy a text type.