Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qyAdM-006Z27-3V for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Nov 2023 12:47:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qyAdJ-007Bri-GM for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Nov 2023 12:47:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qyAdJ-007BrZ-2y for pgsql-hackers@lists.postgresql.org; Wed, 01 Nov 2023 12:47:41 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qyAdG-003Rgu-CN for pgsql-hackers@postgresql.org; Wed, 01 Nov 2023 12:47:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2023062407; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=4f8m0eiB4dRFucUnX8UPoKuagX6S+QZpGtI9fh/KK3o=; b=Np9sc t55ty7x2b6QlPbbOgFG7py/MnMVhiepnLcMivXtSd2iKioPwMjFqbIFsOnQqLqRgEtPnDjB6+YVT2 bVoaik3n6NdrgINOiv2dLB46ZuHtHxszkeXCStVUoSGyE3ZjdacJpxg4qvxhRry6HEfJfGMQWyysj dglug6r65cNQD9tKsJnREEu0OlQ1q4tI5JdrLctlCTkoBrnnWfpGH3AJlBhGl1I/6MKccszJxg81r l/hqYKfw3rgXGLjdmVi0rrGxSvrah5iD1A4uv0MXOzQiEEz/7F9wMFiz3cCFBpSPlVynDygtY9U6d ZSNeY/QRxANoR0TrXA/j+Kge4KvkQ==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1qyAdB-007s8U-2p; Wed, 01 Nov 2023 08:47:33 -0400 Date: Wed, 1 Nov 2023 08:47:33 -0400 From: Bruce Momjian To: Tom Lane Cc: Yugo NAGATA , Alvaro Herrera , pgsql-hackers@postgresql.org Subject: Re: Question about non-blocking mode in libpq Message-ID: References: <20210719231129.b2ab655c0d0e80545274c86f@sraoss.co.jp> <202107201605.b3hmz4g6uqqz@alvherre.pgsql> <20210721101509.7e70e0f801a4457a2f6a6174@sraoss.co.jp> <2604997.1698775114@sss.pgh.pa.us> <2666892.1698801066@sss.pgh.pa.us> <2674201.1698804967@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="l7YJmV3Khvu9kbiP" Content-Disposition: inline In-Reply-To: <2674201.1698804967@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --l7YJmV3Khvu9kbiP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Oct 31, 2023 at 10:16:07PM -0400, Tom Lane wrote: > Bruce Momjian writes: > > On Tue, Oct 31, 2023 at 09:11:06PM -0400, Tom Lane wrote: > >> What I'm objecting to is removal of the bit about "if they need to be > >> called again". That provides a hint that retry is the appropriate > >> response to a failure. Admittedly, it's not 100% clear, but your > >> version makes it 0% clear. > > > I thought the original docs said you had to re-call on failure (it would > > not block but it would fail if it could not be sent), while we are now > > saying that it will be queued in the input buffer. > > For these functions in nonblock mode, failure means "we didn't queue it". > > > Is retry really something we need to mention now? If out of memory is > > our only failure case now ("unable to enlarge the buffer because OOM"), > > is retry really a realistic option? > > Well, ideally the application would do something to alleviate the > OOM problem before retrying. I don't know if we want to go so far > as to discuss that. I do object to giving the impression that > failure is impossible, which I think your proposed wording does. > > An orthogonal issue with your latest wording is that it's unclear > whether *unsuccessful* calls to these functions will block. Okay, I see your point now. Here is an updated patch that addresses both issues. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you. --l7YJmV3Khvu9kbiP Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="block.diff" diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 64b2910fee..ffff0e528d 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -5316,11 +5316,12 @@ int PQsetnonblocking(PGconn *conn, int arg); - In the nonblocking state, calls to + In the nonblocking state, successful calls to , , , , - and will not block but instead return - an error if they need to be called again. + and will not block; their changes + are stored in the local output buffer until they are flushed. + Unsuccessful calls will return an error and must be retried. --l7YJmV3Khvu9kbiP--