Bug in libpq causes local clients to hang

From: "Jeffrey Baker" <jwbaker(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Bug in libpq causes local clients to hang
Date: 2008-03-24 02:12:34
Message-ID: fd145f7d0803231912g1e3541eay8ab952c26168789d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Lately I've noticed that local (UNIX socket) clients using libpq4
8.1.9 (Debian 8.1.9-0etch1) and the same version of the server can
hang forever waiting in poll(). The symptom is that the local client
waits forever, using no CPU time, until it is interrupted by some
event (such as attaching gdb or strace to it), after which it proceeds
normally. From the server's perspective, such clients are in the
state "<IDLE> in transaction" as reported via pg_stat_activity. I
attached GDB to one such client, and the stack trace is as follows:

#0 0x00002b4f2f914d7f in poll () from /lib/libc.so.6
#1 0x00002b4f3038449f in PQmblen () from /usr/lib/libpq.so.4
#2 0x00002b4f30384580 in pqWaitTimed () from /usr/lib/libpq.so.4
#3 0x00002b4f30383e62 in PQgetResult () from /usr/lib/libpq.so.4
#4 0x00002b4f30383f3e in PQgetResult () from /usr/lib/libpq.so.4
#5 0x00002b4f3025f014 in dbd_st_execute () from
/usr/lib/perl5/auto/DBD/Pg/Pg.so
#6 0x00002b4f302548b6 in XS_DBD__Pg__db_do () from
/usr/lib/perl5/auto/DBD/Pg/Pg.so
#7 0x00002b4f2fd201f0 in XS_DBI_dispatch () from /usr/lib/perl5/auto/DBI/DBI.so
#8 0x00002b4f2f310b95 in Perl_pp_entersub () from /usr/lib/libperl.so.5.8
#9 0x00002b4f2f30f36e in Perl_runops_standard () from /usr/lib/libperl.so.5.8
#10 0x00002b4f2f2ba7dc in perl_run () from /usr/lib/libperl.so.5.8
#11 0x00000000004017ac in main ()

You'll note that I'm using the DBD::Pg Perl interface. So far I've
never seen this happen with TCP connections, only with UNIX sockets.
I see it with about 1 in 100 local client invocations.

As a workaround I've configured my local clients to use TCP anyway,
and this seems to solve the problem. Is this something that might
have been fixed in a post-8.1 version of libpq?

-jwb

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeffrey Baker 2008-03-24 02:17:15 Re: Bug in libpq causes local clients to hang
Previous Message Andrew Dunstan 2008-03-24 00:56:57 Re: TODO Item: Consider allowing control of upper/lower case folding of unquoted, identifiers