Skip to content

Commit 71aa2e1

Browse files
Add CHECK_FOR_INTERRUPTS in Evict{Rel,All}UnpinnedBuffers.
This commit adds CHECK_FOR_INTERRUPTS to the shared buffer iteration loops in EvictRelUnpinnedBuffers and EvictAllUnpinnedBuffers. These functions, used by pg_buffercache's pg_buffercache_evict_relation and pg_buffercache_evict_all, can now be interrupted during long-running operations. Backpatch to version 18, where these functions and their corresponding pg_buffercache functions were introduced. Author: Yuhang Qiu <iamqyh@gmail.com> Discussion: https://postgr.es/m/8DC280D4-94A2-4E7B-BAB9-C345891D0B78%40gmail.com Backpatch-through: 18
1 parent 8733f0b commit 71aa2e1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/backend/storage/buffer/bufmgr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6683,6 +6683,8 @@ EvictAllUnpinnedBuffers(int32 *buffers_evicted, int32 *buffers_flushed,
66836683
uint32 buf_state;
66846684
bool buffer_flushed;
66856685

6686+
CHECK_FOR_INTERRUPTS();
6687+
66866688
buf_state = pg_atomic_read_u32(&desc->state);
66876689
if (!(buf_state & BM_VALID))
66886690
continue;
@@ -6733,6 +6735,8 @@ EvictRelUnpinnedBuffers(Relation rel, int32 *buffers_evicted,
67336735
uint32 buf_state = pg_atomic_read_u32(&(desc->state));
67346736
bool buffer_flushed;
67356737

6738+
CHECK_FOR_INTERRUPTS();
6739+
67366740
/* An unlocked precheck should be safe and saves some cycles. */
67376741
if ((buf_state & BM_VALID) == 0 ||
67386742
!BufTagMatchesRelFileLocator(&desc->tag, &rel->rd_locator))

0 commit comments

Comments
 (0)