pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Murray S. Kucherawy <msk@cloudmark.com>
To: Robert Haas <robertmhaas@gmail.com>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #5837: PQstatus() fails to report lost connection
Date: Tue, 25 Jan 2011 10:01:58 -0800
Message-ID: <F5833273385BB34F99288B3648C4F06F1341E7400C@EXCH-C2.corp.cloudmark.com> (raw)
In-Reply-To: <AANLkTi=vbzmBP9MyDvXcOOTRuzPMPYY5cEVfO+haDkrN@mail.gmail.com>
References: <201101140136.p0E1aTFb017852@wwwmaster.postgresql.org>
	<AANLkTinZAdPCX685ecg2_eVXJ1vDNXL4Ki-B1rFN=Z3h@mail.gmail.com>
	<1950.1295754244@sss.pgh.pa.us>
	<F5833273385BB34F99288B3648C4F06F1341E73FC4@EXCH-C2.corp.cloudmark.com>
	<AANLkTi=rSATsN+3UD5feWm3ntsB=6jqAFBZWdTZ7ZfaO@mail.gmail.com>
	<F5833273385BB34F99288B3648C4F06F1341E73FC6@EXCH-C2.corp.cloudmark.com>
	<6493.1295882981@sss.pgh.pa.us>
	<F5833273385BB34F99288B3648C4F06F1341E73FCB@EXCH-C2.corp.cloudmark.com>
	<4D3D67600200002500039B2C@gw.wicourts.gov>
	<F5833273385BB34F99288B3648C4F06F1341E73FCD@EXCH-C2.corp.cloudmark.com>
	<4D3D74D60200002500039B3C@gw.wicourts.gov>
	<AANLkTi=vbzmBP9MyDvXcOOTRuzPMPYY5cEVfO+haDkrN@mail.gmail.com>

> -----Original Message-----
> From: Robert Haas [mailto:robertmhaas@gmail.com]
> Sent: Tuesday, January 25, 2011 7:33 AM
> To: Kevin Grittner
> Cc: Murray S. Kucherawy; Tom Lane; pgsql-bugs@postgresql.org
> Subject: Re: [BUGS] BUG #5837: PQstatus() fails to report lost connection
> 
> I think the real, underlying problem here is that Murray would like a
> behavior change: when a FATAL or PANIC condition is reported by the
> server, he'd like the client to immediately close the socket and set
> its status to CONNECTION_BAD.  If we're going to clarify the
> documentation, I think that the lack of that behavior is what we
> should try to clarify.  For example, it would be good to mention that
> a PGRES_FATAL_ERROR is might corresponding to the server levels ERROR,
> FATAL, or PANIC, and that only in the latter two cases is the
> connection presumably of no further use; and we could also mention
> that libpq doesn't understand anything about the meanings of those
> error levels, so that PQstatus() won't automatically barf just because
> the server has sent a FATAL, *unless* it's read far enough in the
> input stream to detect the problem.

First and foremost, I think a behavior change would be the right thing to do.  I can't think of any API that follows this odd model; to me it's like saying select() has reported a socket that's both read-ready and in an exception state, but we won't actually set errno until you iterate on read() until EOF first.  Counter-intuitive behaviors in APIs lead to application problems or even user attrition in extreme cases.

That said, I've maintained complex APIs before (in fact, this is all the result of one of them) and I understand what this sort of a change might entail.  Thus, the next-best option is to document the idiosyncrasy that's been uncovered; i.e., make the proposed change to the documentation with perhaps an added hint as to why it's necessary.  You might want to demonstrate why after one iteration PGgetResult() and PQstatus() seem to indicate no problem while PGresultStatus() and PGresultErrorString() both already seem to know the severity and even the nature of the error.

I think Kevin summed it up nicely.  Quite simply, the documentation doesn't match the behavior in this case.  One or the other should be adjusted so they are in alignment, while disrupting both your installed base and user experience as little as possible.

-MSK



view thread (25+ messages)  latest in thread

Message-ID: <F5833273385BB34F99288B3648C4F06F1341E7400C@EXCH-C2.corp.cloudmark.com>
Permalink:  ../F5833273385BB34F99288B3648C4F06F1341E7400C@EXCH-C2.corp.cloudmark.com/
Also on:    postgresql.org/message-id/F5833273385BB34F99288B3648C4F06F1341E7400C@EXCH-C2.corp.cloudmark.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: msk@cloudmark.com, robertmhaas@gmail.com, Kevin.Grittner@wicourts.gov, tgl@sss.pgh.pa.us
  Subject: Re: BUG #5837: PQstatus() fails to report lost connection
  In-Reply-To: <F5833273385BB34F99288B3648C4F06F1341E7400C@EXCH-C2.corp.cloudmark.com>
  References: <201101140136.p0E1aTFb017852@wwwmaster.postgresql.org> <AANLkTinZAdPCX685ecg2_eVXJ1vDNXL4Ki-B1rFN=Z3h@mail.gmail.com> <1950.1295754244@sss.pgh.pa.us> <F5833273385BB34F99288B3648C4F06F1341E73FC4@EXCH-C2.corp.cloudmark.com> <AANLkTi=rSATsN+3UD5feWm3ntsB=6jqAFBZWdTZ7ZfaO@mail.gmail.com> <F5833273385BB34F99288B3648C4F06F1341E73FC6@EXCH-C2.corp.cloudmark.com> <6493.1295882981@sss.pgh.pa.us> <F5833273385BB34F99288B3648C4F06F1341E73FCB@EXCH-C2.corp.cloudmark.com> <4D3D67600200002500039B2C@gw.wicourts.gov> <F5833273385BB34F99288B3648C4F06F1341E73FCD@EXCH-C2.corp.cloudmark.com> <4D3D74D60200002500039B3C@gw.wicourts.gov> <AANLkTi=vbzmBP9MyDvXcOOTRuzPMPYY5cEVfO+haDkrN@mail.gmail.com> <F5833273385BB34F99288B3648C4F06F1341E7400C@EXCH-C2.corp.cloudmark.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox