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 1qecXv-007I4B-DA for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Sep 2023 14:33:19 +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 1qecXt-00B4Ds-Jp for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Sep 2023 14:33:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qecXt-00B4DX-Ad for pgsql-bugs@lists.postgresql.org; Fri, 08 Sep 2023 14:33:17 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qecXp-003uC7-Et for pgsql-bugs@lists.postgresql.org; Fri, 08 Sep 2023 14:33:16 +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 388EXBB01876132; Fri, 8 Sep 2023 10:33:11 -0400 From: Tom Lane To: mah0x211@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18096: In edge-triggered epoll and kqueue, PQconsumeInput/PQisBusy are insufficient for correct async ops. In-reply-to: <18096-2bd930f8f132fb4e@postgresql.org> References: <18096-2bd930f8f132fb4e@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 08 Sep 2023 00:26:01 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1876130.1694183591.1@sss.pgh.pa.us> Date: Fri, 08 Sep 2023 10:33:11 -0400 Message-ID: <1876131.1694183591@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > When processing asynchronous commands, I call the `PQconsumeInput` and > `PQisBusy` functions to check if data has arrived, as shown below, but this > does not work correctly in edge trigger mode for epoll and kqueue. You have not really provided any evidence of a bug. The contract for PQconsumeInput is that it will consume *some* input if any is available, not that it will consume *all* available input. (I don't think there is much reason to try to change that. In the first place, there might not be enough buffer space, and in the second place, even if it did consume all input, more might arrive immediately after it looks.) Without a self-contained test case, it's hard to be sure what is going wrong for you; but my guess is that this is a bug in the way you are checking for more available input rather than something libpq did wrong. > However, the `pqReadData()` function will not call the `pqsecure_read()` > function until the `errno` is set to `EAGAIN` or `EWOULDBLOCK`, Uh ... what? regards, tom lane