Skip site navigation (1) Skip section navigation (2)

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

From: Prima Chairunnanda <prima(dot)ch(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Backend freezes at "idle in transaction" while using libpq PQexec (PostgreSQL version 9.1.2)
Date: 2012-07-20 23:27:44
Message-ID: CAHfRcyprAFxb_1+C_ei9WGNdod22YwNCgUU=gv2YMCotPOHYrQ@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi everyone,

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!
The following are the backtrace for both front-end and back-end. Take note
that some line numbers in postgres.c and postmaster.c might differ, as I
have made some small modifications in both files (but not anything to do
with messaging). They are based on PostgreSQL source 9.1.2.

Backtrace at the back-end:
*#0  0x0000003e9da0dc35 in recv () from /lib64/libpthread.so.0*
*#1  0x00000000005ede95 in secure_read (port=0xc83b6b0, ptr=0xc039e0,
len=8192)*
*    at be-secure.c:303*
#2  0x00000000005f8406 in pq_recvbuf () at pqcomm.c:816
#3  0x00000000005f84a9 in pq_getbyte () at pqcomm.c:857
#4  0x00000000006d1169 in SocketBackend (inBuf=0x7fff26266bc0)
    at postgres.c:342
#5  0x00000000006d1485 in ReadCommand (inBuf=0x7fff26266bc0) at
postgres.c:464
#6  0x00000000006d5a46 in PostgresMain (argc=2, argv=0xc818788,
    username=0xc818750 "xxxxxxxx") at postgres.c:3889
#7  0x00000000006829b3 in BackendRun (port=0xc83b6b0) at postmaster.c:3694
#8  0x00000000006820b0 in BackendStartup (port=0xc83b6b0) at
postmaster.c:3379
#9  0x000000000067f302 in ServerLoop () at postmaster.c:1523
#10 0x000000000067eaa8 in PostmasterMain (argc=5, argv=0xc8166b0)
    at postmaster.c:1184
#11 0x00000000005fa86f in main (argc=5, argv=0xc8166b0) at main.c:199

While the backtrace at the front-end:
*#0  0x0000003e9cecb186 in poll () from /lib64/libc.so.6*
*#1  0x00002aee34f6a686 in pqSocketPoll (sock=65, forRead=1, forWrite=0, *
*    end_time=-1) at fe-misc.c:1066*
#2  0x00002aee34f6a568 in pqSocketCheck (conn=0xd127b20, forRead=1,
    forWrite=0, end_time=-1) at fe-misc.c:1008
#3  0x00002aee34f6a431 in pqWaitTimed (forRead=1, forWrite=0,
conn=0xd127b20,
    finish_time=-1) at fe-misc.c:940
#4  0x00002aee34f6a406 in pqWait (forRead=1, forWrite=0, conn=0xd127b20)
    at fe-misc.c:923
#5  0x00002aee34f66438 in PQgetResult (conn=0xd127b20) at fe-exec.c:1537
#6  0x00002aee34f66b44 in PQexecFinish (conn=0xd127b20) at fe-exec.c:1803
#7  0x00002aee34f6678a in PQexec (conn=0xd127b20,

So I am wondering how both of them can be waiting to receive message
(presumably from each other).

Thank you in advance for your help. Any hints as to how to deal with this
is much appreciated.


Regards,

Prima

Responses

pgsql-novice by date

Next:From: Ioannis AnagnostopoulosDate: 2012-07-20 23:56:34
Subject: Re: A very long running query....
Previous:From: Tom LaneDate: 2012-07-20 23:10:02
Subject: Re: A very long running query....

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group