[GENERAL] libpq: PQreset not reconnecting connection, even though server is running - Mailing list pgsql-general

From Geoff Winkless
Subject [GENERAL] libpq: PQreset not reconnecting connection, even though server is running
Date
Msg-id CAEzk6fcMQog5B2_HAt9BepNj0myy28TTeBzjHB1agdNCUmtxDg@mail.gmail.com
Whole thread Raw
Responses Re: [GENERAL] libpq: PQreset not reconnecting connection, even though server is running
List pgsql-general
Hi

I have code in our "run this query" shim that automatically attempts
to reconnect to the server if it finds that the connection is bad
(usually it's just there to handle unexpected postmaster restarts).

   while (PQstatus(Conn) == CONNECTION_BAD) {     fprintf(stderr, "postgres connection status is CONNECTION_BAD:
attempting to reconnect\n");     PQreset(Conn);     if (PQstatus(Conn) == CONNECTION_BAD) {       usleep(1000000);
}  }
 

Yesterday, we found that one (just-created) thread had got stuck in
this loop, even though all other processes were still talking to the
server with no problems.

Around the time of the first failure we got a message about
"incomplete startup packet" in the postgres log.

I'm guessing (from "incomplete startup packet") that the connection
created by the new thread never actually succeeded, is that the
problem? Will PQreset only work on a connection that had previously
connected successfully?

If that _is_ the case, is there a way to tell up-front whether this is
the case (so I can retry PQconnectdb instead of calling PQreset)?

Thanks

Geoff


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: Don Seiler
Date:
Subject: Re: [GENERAL] Allow only certain query on replication slave
Next
From: Geoff Winkless
Date:
Subject: Re: [GENERAL] libpq: PQreset not reconnecting connection, even though server is running