postgres.git / summary / log / commit / refs

commit    eb9ee4d1818cd228d80049fd42efbfaabc187c20
Author:   Masahiko Sawada <msawada@postgresql.org>
Date:     Tue Aug 19 19:11:32 2025 +0000
First released in: 13.23, 14.20, 15.15, 16.11, 17.7, 18.0

    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


contrib/pg_buffercache/pg_buffercache_pages.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c index 1bd579fcbb0..206b809d04d 100644 --- a/contrib/pg_buffercache/pg_buffercache_pages.c +++ b/contrib/pg_buffercache/pg_buffercache_pages.c @@ -11,6 +11,7 @@ #include "access/htup_details.h" #include "catalog/pg_type.h" #include "funcapi.h" +#include "miscadmin.h" #include "storage/buf_internals.h" #include "storage/bufmgr.h" @@ -148,6 +149,8 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) BufferDesc *bufHdr; uint32 buf_state; + CHECK_FOR_INTERRUPTS(); + bufHdr = GetBufferDescriptor(i); /* Lock each buffer header before inspecting. */ buf_state = LockBufHdr(bufHdr); [parent: e41137155869]