X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0C13152A80 for ; Fri, 8 Jul 2005 00:24:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84176-02 for ; Fri, 8 Jul 2005 03:24:21 +0000 (GMT) Received: from smtp-vbr1.xs4all.nl (smtp-vbr1.xs4all.nl [194.109.24.21]) by svr1.postgresql.org (Postfix) with ESMTP id 5002B52A46 for ; Fri, 8 Jul 2005 00:24:18 -0300 (ADT) Received: from webmail.xs4all.nl (webmail12.xs4all.nl [194.109.22.172]) by smtp-vbr1.xs4all.nl (8.13.3/8.13.3) with ESMTP id j683OGWL099868; Fri, 8 Jul 2005 05:24:16 +0200 (CEST) (envelope-from jtv@xs4all.nl) Received: from 202.47.227.25 by webmail.xs4all.nl with HTTP; Fri, 8 Jul 2005 05:24:16 +0200 (CEST) Message-ID: <10014.202.47.227.25.1120793056.squirrel@202.47.227.25> In-Reply-To: <28109.1120669187@sss.pgh.pa.us> References: <21028.202.47.227.25.1120571298.squirrel@202.47.227.25> <13032.1120574589@sss.pgh.pa.us> <24362.202.47.227.25.1120635552.squirrel@202.47.227.25> <28109.1120669187@sss.pgh.pa.us> Date: Fri, 8 Jul 2005 05:24:16 +0200 (CEST) Subject: Re: libpq and connection failures From: jtv@xs4all.nl To: "Tom Lane" Cc: jtv@xs4all.nl, pgsql-interfaces@postgresql.org User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by XS4ALL Virus Scanner X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.228 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200507/14 X-Sequence-Number: 5650 Tom Lane wrote: >>> I think it's probably better to have the default assumption be >>> "connection possibly recoverable" than have it be "summarily kill >>> connection at first hint of trouble". The latter seems less robust >>> not more so. > >> Not after the connection failure has made its way into a PGresult, >> surely? > > Well, I've not had a whole lot of personal experience with flaky > connections to a database ... what do other people think would be > the most useful behavior? I can only speak for libpqxx and some of its users. One has pulled a network cable out and found that the error he ultimately received (after a long timeout) looked like a query failure--and PQstatus still said CONNECTION_OK, leaving libpqxx unable to diagnose the error type and throw the appropriate exception type. Searching for the error text brought us to the scene of the crime. I don't see how this state of affairs can be acceptable *at all* given that PQstatus exists and purports to report a connection's status. If pulling out the network cable and not putting it back fails to meet our definition of a broken connection, what meets it? Another user ran into trouble because he couldn't connect to the database due to an incorrectly formatted connection string, but didn't receive an error. Instead he got a PGconn that as far as I can make out, seemed fully functional (non-NULL and CONNECTION_OK), but wasn't. We happened to discover what was going on because he printed out the result of PQdb() without checking for a NULL result, and reported the resulting crash to the libpqxx mailing list. Jeroen