Add CHECK_FOR_INTERRUPTS in pg_buffercache_pages while scanning the buffers
Please find attached patch that adds CHECK_FOR_INTERRUPTS while scanning
the buffers in pg_buffercache_pages. I checked other functions in the
module and this check already exists in pg_buffercache_numa_pages.
Thanks,
Satya
Attachments:
pg_buffercache_interrupt_check.patchapplication/octet-stream; name=pg_buffercache_interrupt_check.patchDownload
diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c
index ae0291e6e96..5afe4c3765e 100644
--- a/contrib/pg_buffercache/pg_buffercache_pages.c
+++ b/contrib/pg_buffercache/pg_buffercache_pages.c
@@ -193,6 +193,8 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
{
BufferDesc *bufHdr;
uint32 buf_state;
+
+ CHECK_FOR_INTERRUPTS();
bufHdr = GetBufferDescriptor(i);
/* Lock each buffer header before inspecting. */
@@ -560,6 +562,8 @@ pg_buffercache_summary(PG_FUNCTION_ARGS)
BufferDesc *bufHdr;
uint32 buf_state;
+ CHECK_FOR_INTERRUPTS();
+
/*
* This function summarizes the state of all headers. Locking the
* buffer headers wouldn't provide an improved result as the state of
@@ -620,6 +624,8 @@ pg_buffercache_usage_counts(PG_FUNCTION_ARGS)
uint32 buf_state = pg_atomic_read_u32(&bufHdr->state);
int usage_count;
+ CHECK_FOR_INTERRUPTS();
+
usage_count = BUF_STATE_GET_USAGECOUNT(buf_state);
usage_counts[usage_count]++;
On Thu, Jul 31, 2025 at 4:31 PM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:
Please find attached patch that adds CHECK_FOR_INTERRUPTS while scanning the buffers in pg_buffercache_pages. I checked other functions in the module and this check already exists in pg_buffercache_numa_pages.
Thank you for the patch!
I think the patch is reasonable and it looks good to me. I'll push it
to master early next week, barring objections.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
On Fri, Aug 8, 2025 at 2:59 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
On Thu, Jul 31, 2025 at 4:31 PM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:Please find attached patch that adds CHECK_FOR_INTERRUPTS while scanning the buffers in pg_buffercache_pages. I checked other functions in the module and this check already exists in pg_buffercache_numa_pages.
Thank you for the patch!
I think the patch is reasonable and it looks good to me. I'll push it
to master early next week, barring objections.
After reviewing this patch more, I'm leaning toward to backpatch this
change. The patch adds CHECK_FOR_INTERRUPTS() to
pg_buffercache_pages(), pg_buffercache_summary(), and
pg_buffercache_usage_counts(), and the latter two functions were
introduced in v16. Therefore, for v15 or older we can add CFI to only
pg_buffercache_pages() and apply this patch to v16 or newer. Thoughts?
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
Hi Masahiko,
On Thu, Aug 14, 2025 at 4:57 PM Masahiko Sawada <sawada.mshk@gmail.com>
wrote:
On Fri, Aug 8, 2025 at 2:59 PM Masahiko Sawada <sawada.mshk@gmail.com>
wrote:On Thu, Jul 31, 2025 at 4:31 PM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:Please find attached patch that adds CHECK_FOR_INTERRUPTS while
scanning the buffers in pg_buffercache_pages. I checked other functions in
the module and this check already exists in pg_buffercache_numa_pages.Thank you for the patch!
I think the patch is reasonable and it looks good to me. I'll push it
to master early next week, barring objections.After reviewing this patch more, I'm leaning toward to backpatch this
change. The patch adds CHECK_FOR_INTERRUPTS() to
pg_buffercache_pages(), pg_buffercache_summary(), and
pg_buffercache_usage_counts(), and the latter two functions were
introduced in v16. Therefore, for v15 or older we can add CFI to only
pg_buffercache_pages() and apply this patch to v16 or newer. Thoughts?
Thanks for reviewing the patch. Sounds good to me.
Thanks,
Satya
On Fri, Aug 15, 2025 at 2:33 AM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:
Hi Masahiko,
On Thu, Aug 14, 2025 at 4:57 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
On Fri, Aug 8, 2025 at 2:59 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
On Thu, Jul 31, 2025 at 4:31 PM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:Please find attached patch that adds CHECK_FOR_INTERRUPTS while scanning the buffers in pg_buffercache_pages. I checked other functions in the module and this check already exists in pg_buffercache_numa_pages.
Thank you for the patch!
I think the patch is reasonable and it looks good to me. I'll push it
to master early next week, barring objections.After reviewing this patch more, I'm leaning toward to backpatch this
change. The patch adds CHECK_FOR_INTERRUPTS() to
pg_buffercache_pages(), pg_buffercache_summary(), and
pg_buffercache_usage_counts(), and the latter two functions were
introduced in v16. Therefore, for v15 or older we can add CFI to only
pg_buffercache_pages() and apply this patch to v16 or newer. Thoughts?Thanks for reviewing the patch. Sounds good to me.
Could you provide patches also for back branches? or shall I?
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
On Fri, Aug 15, 2025 at 12:04 PM Masahiko Sawada <sawada.mshk@gmail.com>
wrote:
On Fri, Aug 15, 2025 at 2:33 AM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:Hi Masahiko,
On Thu, Aug 14, 2025 at 4:57 PM Masahiko Sawada <sawada.mshk@gmail.com>
wrote:
On Fri, Aug 8, 2025 at 2:59 PM Masahiko Sawada <sawada.mshk@gmail.com>
wrote:
On Thu, Jul 31, 2025 at 4:31 PM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:Please find attached patch that adds CHECK_FOR_INTERRUPTS while
scanning the buffers in pg_buffercache_pages. I checked other functions in
the module and this check already exists in pg_buffercache_numa_pages.Thank you for the patch!
I think the patch is reasonable and it looks good to me. I'll push it
to master early next week, barring objections.After reviewing this patch more, I'm leaning toward to backpatch this
change. The patch adds CHECK_FOR_INTERRUPTS() to
pg_buffercache_pages(), pg_buffercache_summary(), and
pg_buffercache_usage_counts(), and the latter two functions were
introduced in v16. Therefore, for v15 or older we can add CFI to only
pg_buffercache_pages() and apply this patch to v16 or newer. Thoughts?Thanks for reviewing the patch. Sounds good to me.
Could you provide patches also for back branches? or shall I?
Attached the patch for v15 and below. Please let me know if you need
anything.
Thanks,
Satya
Attachments:
pg_buffercache_interrupt_check_pg15.patchapplication/octet-stream; name=pg_buffercache_interrupt_check_pg15.patchDownload
diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c
index 1bd579fcbb0..d58a8991f38 100644
--- a/contrib/pg_buffercache/pg_buffercache_pages.c
+++ b/contrib/pg_buffercache/pg_buffercache_pages.c
@@ -148,6 +148,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);
On Mon, Aug 18, 2025 at 11:59 AM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:
On Fri, Aug 15, 2025 at 12:04 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
On Fri, Aug 15, 2025 at 2:33 AM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:Hi Masahiko,
On Thu, Aug 14, 2025 at 4:57 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
On Fri, Aug 8, 2025 at 2:59 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
On Thu, Jul 31, 2025 at 4:31 PM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:Please find attached patch that adds CHECK_FOR_INTERRUPTS while scanning the buffers in pg_buffercache_pages. I checked other functions in the module and this check already exists in pg_buffercache_numa_pages.
Thank you for the patch!
I think the patch is reasonable and it looks good to me. I'll push it
to master early next week, barring objections.After reviewing this patch more, I'm leaning toward to backpatch this
change. The patch adds CHECK_FOR_INTERRUPTS() to
pg_buffercache_pages(), pg_buffercache_summary(), and
pg_buffercache_usage_counts(), and the latter two functions were
introduced in v16. Therefore, for v15 or older we can add CFI to only
pg_buffercache_pages() and apply this patch to v16 or newer. Thoughts?Thanks for reviewing the patch. Sounds good to me.
Could you provide patches also for back branches? or shall I?
Attached the patch for v15 and below. Please let me know if you need anything.
Thank you for the patch! It seems we need to #include miscadmin.h in
v15 and older. I've incorporated that change and pushed.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com