Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8f34811

Browse files
committed
Insert CHECK_FOR_INTERRUPTS() calls into btree and hash index scans at the
points where we step right or left to the next page. This should ensurereasonable response time to a query cancel request during an unsuccessfulindex scan, as seen in recent gripe from Marc Cousin. It's a bit trickierthan it might seem at first glance, because CHECK_FOR_INTERRUPTS() is a no-opif executed while holding a buffer lock. So we have to do it just at thepoint where we've dropped one page lock and not yet acquired the next.Remove CHECK_FOR_INTERRUPTS calls at the top level of btgetbitmap andhashgetbitmap, since they're pointless given the added checks.I think that GIST is okay already --- at least, there's a CHECK_FOR_INTERRUPTSat a plausible-looking place in gistnext(). I don't claim to know GIN wellenough to try to poke it for this, if indeed it has a problem at all.This is a pre-existing issue, but in view of the lack of prior complaintsI'm not going to risk back-patching.
1 parent2aa5ca9 commit8f34811

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

‎src/backend/access/hash/hash.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.109 2009/03/24 20:17:11 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.110 2009/05/05 19:36:32 tgl Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -22,7 +22,6 @@
2222
#include"access/relscan.h"
2323
#include"catalog/index.h"
2424
#include"commands/vacuum.h"
25-
#include"miscadmin.h"
2625
#include"optimizer/cost.h"
2726
#include"optimizer/plancat.h"
2827
#include"storage/bufmgr.h"
@@ -297,8 +296,6 @@ hashgetbitmap(PG_FUNCTION_ARGS)
297296
{
298297
booladd_tuple;
299298

300-
CHECK_FOR_INTERRUPTS();
301-
302299
/*
303300
* Skip killed tuples if asked to.
304301
*/

‎src/backend/access/hash/hashsearch.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hashsearch.c,v 1.55 2009/01/01 17:23:35 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hashsearch.c,v 1.56 2009/05/05 19:36:32 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515
#include"postgres.h"
1616

1717
#include"access/hash.h"
1818
#include"access/relscan.h"
19+
#include"miscadmin.h"
1920
#include"pgstat.h"
2021
#include"storage/bufmgr.h"
2122
#include"utils/rel.h"
@@ -74,6 +75,8 @@ _hash_readnext(Relation rel,
7475
blkno= (*opaquep)->hasho_nextblkno;
7576
_hash_relbuf(rel,*bufp);
7677
*bufp=InvalidBuffer;
78+
/* check for interrupts while we're not holding any buffer lock */
79+
CHECK_FOR_INTERRUPTS();
7780
if (BlockNumberIsValid(blkno))
7881
{
7982
*bufp=_hash_getbuf(rel,blkno,HASH_READ,LH_OVERFLOW_PAGE);
@@ -94,6 +97,8 @@ _hash_readprev(Relation rel,
9497
blkno= (*opaquep)->hasho_prevblkno;
9598
_hash_relbuf(rel,*bufp);
9699
*bufp=InvalidBuffer;
100+
/* check for interrupts while we're not holding any buffer lock */
101+
CHECK_FOR_INTERRUPTS();
97102
if (BlockNumberIsValid(blkno))
98103
{
99104
*bufp=_hash_getbuf(rel,blkno,HASH_READ,

‎src/backend/access/nbtree/nbtree.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.168 2009/03/24 20:17:12 tgl Exp $
15+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.169 2009/05/05 19:36:32 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -24,7 +24,6 @@
2424
#include"catalog/index.h"
2525
#include"catalog/storage.h"
2626
#include"commands/vacuum.h"
27-
#include"miscadmin.h"
2827
#include"storage/bufmgr.h"
2928
#include"storage/freespace.h"
3029
#include"storage/indexfsm.h"
@@ -315,8 +314,6 @@ btgetbitmap(PG_FUNCTION_ARGS)
315314
*/
316315
if (++so->currPos.itemIndex>so->currPos.lastItem)
317316
{
318-
CHECK_FOR_INTERRUPTS();
319-
320317
/* let _bt_next do the heavy lifting */
321318
if (!_bt_next(scan,ForwardScanDirection))
322319
break;

‎src/backend/access/nbtree/nbtsearch.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.119 2009/01/01 17:23:35 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.120 2009/05/05 19:36:32 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -18,6 +18,7 @@
1818
#include"access/genam.h"
1919
#include"access/nbtree.h"
2020
#include"access/relscan.h"
21+
#include"miscadmin.h"
2122
#include"pgstat.h"
2223
#include"storage/bufmgr.h"
2324
#include"utils/lsyscache.h"
@@ -1126,16 +1127,16 @@ _bt_steppage(IndexScanDesc scan, ScanDirection dir)
11261127

11271128
for (;;)
11281129
{
1129-
/* if we're at end of scan, release the buffer and return */
1130+
/* release the previous buffer */
1131+
_bt_relbuf(rel,so->currPos.buf);
1132+
so->currPos.buf=InvalidBuffer;
1133+
/* if we're at end of scan, give up */
11301134
if (blkno==P_NONE|| !so->currPos.moreRight)
1131-
{
1132-
_bt_relbuf(rel,so->currPos.buf);
1133-
so->currPos.buf=InvalidBuffer;
11341135
return false;
1135-
}
1136+
/* check for interrupts while we're not holding any buffer lock */
1137+
CHECK_FOR_INTERRUPTS();
11361138
/* step right one page */
1137-
so->currPos.buf=_bt_relandgetbuf(rel,so->currPos.buf,
1138-
blkno,BT_READ);
1139+
so->currPos.buf=_bt_getbuf(rel,blkno,BT_READ);
11391140
/* check for deleted page */
11401141
page=BufferGetPage(so->currPos.buf);
11411142
opaque= (BTPageOpaque)PageGetSpecialPointer(page);
@@ -1239,7 +1240,10 @@ _bt_walk_left(Relation rel, Buffer buf)
12391240
obknum=BufferGetBlockNumber(buf);
12401241
/* step left */
12411242
blkno=lblkno=opaque->btpo_prev;
1242-
buf=_bt_relandgetbuf(rel,buf,blkno,BT_READ);
1243+
_bt_relbuf(rel,buf);
1244+
/* check for interrupts while we're not holding any buffer lock */
1245+
CHECK_FOR_INTERRUPTS();
1246+
buf=_bt_getbuf(rel,blkno,BT_READ);
12431247
page=BufferGetPage(buf);
12441248
opaque= (BTPageOpaque)PageGetSpecialPointer(page);
12451249

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp