Search Postgresql Archives

libpq: PQreset not reconnecting connection, even though server is running

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux