From: | Geoff Winkless <pgsqladmin(at)geoff(dot)dj> |
---|---|
To: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | libpq: PQreset not reconnecting connection, even though server is running |
Date: | 2017-10-25 12:24:20 |
Message-ID: | CAEzk6fcMQog5B2_HAt9BepNj0myy28TTeBzjHB1agdNCUmtxDg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Geoff Winkless | 2017-10-25 12:29:53 | Re: libpq: PQreset not reconnecting connection, even though server is running |
Previous Message | Don Seiler | 2017-10-24 21:18:06 | Re: Allow only certain query on replication slave |