From: Tom Lane <tgl@sss.pgh.pa.us>
To: Merlin Moncure <mmoncure@gmail.com>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: sequential scans that pick up only deleted records do not honor query cancel or timeout
Date: Tue, 22 May 2012 19:13:12 -0400
Message-ID: <12013.1337728392@sss.pgh.pa.us> (raw)
In-Reply-To: <CAHyXU0xS_0xx92bxsMHfRRgo0e3rS1bg0ngbz9qN=Buee7P32A@mail.gmail.com>
References: <CAHyXU0xPW=JBur1FvC-ZbKXiLNbVzX6-pHGesfJiTqsMLXpYyQ@mail.gmail.com>
<8558.1337720912@sss.pgh.pa.us>
<CAHyXU0xS_0xx92bxsMHfRRgo0e3rS1bg0ngbz9qN=Buee7P32A@mail.gmail.com>
Merlin Moncure <mmoncure@gmail.com> writes:
> On Tue, May 22, 2012 at 4:08 PM, Tom Lane <tgl@sss.pgh.pa.us> 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:
inline patch 1: src/backend/access/heap/heapam.c (+7/-0 lines) download inline-1.patchdiff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.cindex 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, mmoncure@gmail.com
Subject: Re: sequential scans that pick up only deleted records do not honor query cancel or timeout
In-Reply-To: <12013.1337728392@sss.pgh.pa.us>
References: <CAHyXU0xPW=JBur1FvC-ZbKXiLNbVzX6-pHGesfJiTqsMLXpYyQ@mail.gmail.com> <8558.1337720912@sss.pgh.pa.us> <CAHyXU0xS_0xx92bxsMHfRRgo0e3rS1bg0ngbz9qN=Buee7P32A@mail.gmail.com> <12013.1337728392@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox