Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 7BC09EDF370 for ; Tue, 22 May 2012 20:13:26 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SWyGb-0007Hr-Jn for pgsql-bugs@postgresql.org; Tue, 22 May 2012 23:13:26 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q4MNDCR5012014; Tue, 22 May 2012 19:13:12 -0400 (EDT) To: Merlin Moncure cc: pgsql-bugs Subject: Re: sequential scans that pick up only deleted records do not honor query cancel or timeout In-reply-to: References: <8558.1337720912@sss.pgh.pa.us> Comments: In-reply-to Merlin Moncure message dated "Tue, 22 May 2012 17:39:02 -0500" Date: Tue, 22 May 2012 19:13:12 -0400 Message-ID: <12013.1337728392@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201205/160 X-Sequence-Number: 33131 Merlin Moncure writes: > On Tue, May 22, 2012 at 4:08 PM, Tom Lane wrote: >> heapgetpage() seems like the most reasonable place to me, as there we'll >> only be making the check once per page not once per tuple. > ok. this fixes the issue: Well, actually it needs to be a bit earlier than that or it won't stop non-pageatatime scans (cf the return at line 230 in HEAD). I was thinking to place it at the point where we hold no buffer pin, just to save a couple cycles in error cleanup: diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 0d6fe3f0acd38a87af759bd3d5196da504202486..0c67156390a6a1bf1fee0bb39b96e0da8cd55dbb 100644 *** a/src/backend/access/heap/heapam.c --- b/src/backend/access/heap/heapam.c *************** heapgetpage(HeapScanDesc scan, BlockNumb *** 222,227 **** --- 222,234 ---- scan->rs_cbuf = InvalidBuffer; } + /* + * Be sure to check for interrupts at least once per page. Checks at + * higher code levels won't be able to stop a seqscan that encounters + * many pages' worth of consecutive dead tuples. + */ + CHECK_FOR_INTERRUPTS(); + /* read page using selected strategy */ scan->rs_cbuf = ReadBufferExtended(scan->rs_rd, MAIN_FORKNUM, page, RBM_NORMAL, scan->rs_strategy); But thanks for verifying that a check in this function does fix the issue for you. regards, tom lane