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 1mBf9Q-00066r-E4 for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Aug 2021 15:19:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mBf9P-0007XS-BQ for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Aug 2021 15:19:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBf9P-0007XK-4Y for pgsql-bugs@lists.postgresql.org; Thu, 05 Aug 2021 15:19:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBf9N-0002gl-4N for pgsql-bugs@lists.postgresql.org; Thu, 05 Aug 2021 15:19:14 +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 175FJAnV2392579; Thu, 5 Aug 2021 11:19:10 -0400 From: Tom Lane To: Mike Knowsley cc: pgsql-bugs@lists.postgresql.org Subject: Re: Can not cancel a call to a function that has opened a refcursor In-reply-to: <97DA1097-86CD-4B05-A6BC-BF263F388F25@bidorbuy.co.za> References: <97DA1097-86CD-4B05-A6BC-BF263F388F25@bidorbuy.co.za> Comments: In-reply-to Mike Knowsley message dated "Thu, 05 Aug 2021 14:45:19 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2392577.1628176749.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 05 Aug 2021 11:19:09 -0400 Message-ID: <2392578.1628176749@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Mike Knowsley writes: > A request to cancel a call to a function does not cancel the function if= the function has opened a refcursor which it is returning. As far as I can see, there is no such bug; you're just misunderstanding when the query referenced by the cursor will execute. The function test_delay_in_refcursor() sets up the cursor and returns basically immediately (certainly in much less than 2 seconds), so the timeout you have in the JDBC code will never fire. The expected pg_sleep(5) won't execute till you try to fetch something from the refcursor. Trying this manually in psql, I get ... CREATE FUNCTION regression=3D# \timing Timing is on. regression=3D# begin; BEGIN Time: 0.306 ms regression=3D*# select test_delay_in_refcursor(); test_delay_in_refcursor = ------------------------- (1 row) Time: 0.314 ms regression=3D*# fetch from ""; ?column? | pg_sleep = ----------+---------- test | = (1 row) Time: 5005.475 ms (00:05.005) I could have canceled the FETCH (and doing so works); but I'm way too old and slow to cancel the submillisecond setup step. regards, tom lane