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

Re: BUG #5837: PQstatus() fails to report lost connection

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: "Murray S(dot) Kucherawy" <msk(at)cloudmark(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5837: PQstatus() fails to report lost connection
Date: 2011-01-23 02:51:33
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
On Thu, Jan 13, 2011 at 8:36 PM, Murray S. Kucherawy <msk(at)cloudmark(dot)com> wrote:
> The following bug has been logged online:
> Bug reference:      5837
> Logged by:          Murray S. Kucherawy
> Email address:      msk(at)cloudmark(dot)com
> PostgreSQL version: 9.0.2
> Operating system:   FreeBSD
> Description:        PQstatus() fails to report lost connection
> Details:
> I'm accessing libpq via OpenDBX, but it appears to be doing the right thing.
>  This is reproducible.
> 1) establish a connection to postgresql
> 2) initiate a query, collect results, etc.; all normal
> 3) while client is idle, restart the server
> 4) initiate the very same query as before
> 5) call PQgetResult(), returns non-NULL
> 6) call PQresultStatus(), returns PGRES_FATAL_ERROR
> 7) call PQstatus(), returns CONNECTION_OK
> This causes the caller not to try PQreset() or equivalent, because the
> connection is presumably fine.  However, of course, no further queries will
> succeed.

I can reproduce this by hacking up src/test/examples/testlibpq to
loop, but I'm not totally sure what's causing the behavior.  I think
the problem may be that libpq only reads enough from the connection to
get the FATAL error.  It doesn't keep reading to see whether there's
an EOF afterward, and thus doesn't immediately realize that the
connection has been closed.

Robert Haas
The Enterprise PostgreSQL Company

In response to


pgsql-bugs by date

Next:From: Tom LaneDate: 2011-01-23 03:44:04
Subject: Re: BUG #5837: PQstatus() fails to report lost connection
Previous:From: Robert HaasDate: 2011-01-21 17:59:31
Subject: Re: BUG #5841: rank()+1 fails, 1+rank() succeeds

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