public inbox for [email protected]
help / color / mirror / Atom feedFrom: Lakshmi N <[email protected]>
To: Dapeng Wang <[email protected]>
Cc: [email protected]
Subject: Re: Add missing CHECK_FOR_INTERRUPTS in autovacuum catalog scan loops
Date: Fri, 10 Apr 2026 22:02:02 -0700
Message-ID: <CA+3i_M_Jwy2T+L+wT_4yXKG8r1yQFJt3+Gm5wbxap5hKyy_nzA@mail.gmail.com> (raw)
In-Reply-To: <CAKx0YhxRYuWCSC3mCTJ0VRn0iM8v0G=7vku=3Wg7pyi+rN-=Jw@mail.gmail.com>
References: <CA+3i_M9+A5Wx_o3d3UHcxVU_yfes+a1b8za4VgmWTY_Odc7qMA@mail.gmail.com>
<CAKx0YhxRYuWCSC3mCTJ0VRn0iM8v0G=7vku=3Wg7pyi+rN-=Jw@mail.gmail.com>
Hi,
On Fri, Apr 10, 2026 at 4:57 AM Dapeng Wang <[email protected]>
wrote:
> Lakshmi N <[email protected]> 于2026年4月10日周五 16:39写道:
>
>> Hi hackers,
>>
>> I noticed CFI is missing while scanning pg_class for RELKIND_RELATION and
>> RELKIND_TOASTVALUE. On a database with several thousands of tables, these
>> scans can take a noticeable amount of time. Attached a patch to address
>> this.
>>
>> Regards,
>> Lakshmi
>>
> Hi Lakshmi,
>
> The patch applies cleanly to HEAD and compiles without warnings.
> make check passes (one unrelated ICU collation diff).
>
> The two CHECK_FOR_INTERRUPTS() additions in do_autovacuum() look
> correct and are well-placed at the top of each loop iteration,
> before any resources are acquired.
>
> I noticed there are other similar catalog scan loops in
> autovacuum.c that also lack CHECK_FOR_INTERRUPTS():
>
> - The pg_database scan loop around line 1854
> - The pg_class scan loop around line 3664
>
> Should those be covered as well?
>
Updated the patch covering those two as well.
Regards,
Lakshmi
>
Attachments:
[application/octet-stream] v2-0001-Add-CHECK_FOR_INTERRUPTS-in-autovacuum-table-scannin.patch (1.4K, 3-v2-0001-Add-CHECK_FOR_INTERRUPTS-in-autovacuum-table-scannin.patch)
download | inline diff:
From d2d31987d2e479a8d92494644c183c8bd2f749b2 Mon Sep 17 00:00:00 2001
From: Lakshmi N <[email protected]>
Date: Fri, 10 Apr 2026 01:39:04 -0700
Subject: [PATCH] Add CHECK_FOR_INTERRUPTS in autovacuum table-scanning loops
---
src/backend/postmaster/autovacuum.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 82061247988..5e36137925a 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1859,6 +1859,8 @@ get_database_list(void)
avw_dbase *avdb;
MemoryContext oldcxt;
+ CHECK_FOR_INTERRUPTS();
+
/*
* If database has partially been dropped, we can't, nor need to,
* vacuum it.
@@ -2042,6 +2044,8 @@ do_autovacuum(void)
bool wraparound;
AutoVacuumScores scores;
+ CHECK_FOR_INTERRUPTS();
+
if (classForm->relkind != RELKIND_RELATION &&
classForm->relkind != RELKIND_MATVIEW)
continue;
@@ -2146,6 +2150,8 @@ do_autovacuum(void)
bool wraparound;
AutoVacuumScores scores;
+ CHECK_FOR_INTERRUPTS();
+
/*
* We cannot safely process other backends' temp tables, so skip 'em.
*/
@@ -3669,6 +3675,8 @@ pg_stat_get_autovacuum_scores(PG_FUNCTION_ARGS)
Datum vals[10];
bool nulls[10] = {false};
+ CHECK_FOR_INTERRUPTS();
+
/* skip ineligible entries */
if (form->relkind != RELKIND_RELATION &&
form->relkind != RELKIND_MATVIEW &&
--
2.43.0
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Add missing CHECK_FOR_INTERRUPTS in autovacuum catalog scan loops
In-Reply-To: <CA+3i_M_Jwy2T+L+wT_4yXKG8r1yQFJt3+Gm5wbxap5hKyy_nzA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox