Re: Backend freezes at "idle in transaction" while using libpq PQexec (PostgreSQL version 9.1.2)
В списке pgsql-novice по дате отправления:
| От | 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 по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера