Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mttxu-0007s3-Ag for pgsql-general@arkaria.postgresql.org; Sun, 05 Dec 2021 16:02:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mttxt-0007a1-07 for pgsql-general@arkaria.postgresql.org; Sun, 05 Dec 2021 16:02:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mttxs-0007Zs-Li for pgsql-general@lists.postgresql.org; Sun, 05 Dec 2021 16:02:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mttxj-0007vg-Lo for pgsql-general@lists.postgresql.org; Sun, 05 Dec 2021 16:02:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1B5G1sON2813629; Sun, 5 Dec 2021 11:01:55 -0500 From: Tom Lane To: Daniel Frey cc: Laurenz Albe , pgsql-general Subject: Re: libpq: Which functions may hang due to network issues? In-reply-to: References: <2B29B70E-2A78-49D3-9861-5DD289DC30DD@gmx.de> <0F84CF07-A88E-41A3-B41D-984EA6385AA2@gmx.de> <2311007.1638551661@sss.pgh.pa.us> <36a1a59fcf09deec95b3abdec979d4d6b64a1a4a.camel@cybertec.at> Comments: In-reply-to Daniel Frey message dated "Sun, 05 Dec 2021 11:23:49 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2813627.1638720114.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 05 Dec 2021 11:01:54 -0500 Message-ID: <2813628.1638720114@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Daniel Frey writes: > With all that said, I think that PostgreSQL/libpq should have a clear, d= ocumented way to get rid of a connection that is guaranteed to not hang. I= t has something similar for almost all other methods like opening connecti= ons, sending request, retrieving results. Why stop there? AFAICS, PQfinish() already acts that way, at least up to the same level of guarantee as you have for "all other methods". That is, if you previously set the connection into nonblock mode, it won't block. regards, tom lane