pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jtv@xs4all.nl
To: pgsql-interfaces@postgresql.org
Subject: libpq and connection failures
Date: Tue, 5 Jul 2005 15:48:18 +0200 (CEST)
Message-ID: <21028.202.47.227.25.1120571298.squirrel@202.47.227.25> (raw)

Is there any reason why pqReadData() (interfaces/libpq/fe-misc.c), if
pqsecure_read() fails with an error that isn't special-cased as a
transient one, returns -1 but leaves the connection state at
CONNECTION_OK?  Was this meant to be caught by calling pqReadReady()
(which doesn't happen in this case because of the return)?

Some libpqxx users with postgres 8.0 installed have observed broken
backend connections leading to errors but not updating connection state
accordingly.  One user unplugged his network cable, leading to a long
timeout followed by the error message "could not receive data from
server," but libpqxx was unable to diagnose the situation because
PQstatus() blithely returned CONNECTION_OK.

Doesn't it make more sense in these cases to "goto definitelyFailed"
instead of "return -1" as it does now?

This occurs in two places BTW, so it may make sense to refactor the
function before changing it: the code blocks at labels retry3 and retry4
are completely identical AFAICS except for one small "if" clause (plus a
variable is replaced by 0 where it's provably equal to zero).  Each is
really a switch within a loop, disguised as a nested if through cunning
use of goto.


Jeroen





view thread (5+ messages)  latest in thread

Message-ID: <21028.202.47.227.25.1120571298.squirrel@202.47.227.25>
Permalink:  ../21028.202.47.227.25.1120571298.squirrel@202.47.227.25/
Also on:    postgresql.org/message-id/21028.202.47.227.25.1120571298.squirrel@202.47.227.25

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: jtv@xs4all.nl
  Subject: Re: libpq and connection failures
  In-Reply-To: <21028.202.47.227.25.1120571298.squirrel@202.47.227.25>

* 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