Skip to content

Commit eab9e4e

Browse files
Add CHECK_FOR_INTERRUPTS in contrib/pg_buffercache functions.
This commit adds CHECK_FOR_INTERRUPTS to loops iterating over shared buffers in several pg_buffercache functions, allowing them to be interrupted during long-running operations. Backpatch to all supported versions. Add CHECK_FOR_INTERRUPTS to the loop in pg_buffercache_pages() in all supported branches, and to pg_buffercache_summary() and pg_buffercache_usage_counts() in version 16 and newer. Author: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com> Discussion: https://postgr.es/m/CAHg+QDcejeLx7WunFT3DX6XKh1KshvGKa8F5au8xVhqVvvQPRw@mail.gmail.com Backpatch-through: 13
1 parent c6abf24 commit eab9e4e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

contrib/pg_buffercache/pg_buffercache_pages.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
194194
BufferDesc *bufHdr;
195195
uint32 buf_state;
196196

197+
CHECK_FOR_INTERRUPTS();
198+
197199
bufHdr = GetBufferDescriptor(i);
198200
/* Lock each buffer header before inspecting. */
199201
buf_state = LockBufHdr(bufHdr);
@@ -560,6 +562,8 @@ pg_buffercache_summary(PG_FUNCTION_ARGS)
560562
BufferDesc *bufHdr;
561563
uint32 buf_state;
562564

565+
CHECK_FOR_INTERRUPTS();
566+
563567
/*
564568
* This function summarizes the state of all headers. Locking the
565569
* buffer headers wouldn't provide an improved result as the state of
@@ -620,6 +624,8 @@ pg_buffercache_usage_counts(PG_FUNCTION_ARGS)
620624
uint32 buf_state = pg_atomic_read_u32(&bufHdr->state);
621625
int usage_count;
622626

627+
CHECK_FOR_INTERRUPTS();
628+
623629
usage_count = BUF_STATE_GET_USAGECOUNT(buf_state);
624630
usage_counts[usage_count]++;
625631

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy