Thread

  1. Add missing CHECK_FOR_INTERRUPTS in autovacuum catalog scan loops

    Lakshmi N <lakshmin.jhs@gmail.com> — 2026-04-10T08:38:53Z

    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
    
  2. Re: Add missing CHECK_FOR_INTERRUPTS in autovacuum catalog scan loops

    Dapeng Wang <wangdp20191008@gmail.com> — 2026-04-10T11:57:22Z

    Lakshmi N <lakshmin.jhs@gmail.com> 于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?
    
    Regards,
    Dapeng Wang
    
  3. Re: Add missing CHECK_FOR_INTERRUPTS in autovacuum catalog scan loops

    Lakshmi N <lakshmin.jhs@gmail.com> — 2026-04-11T05:02:02Z

    Hi,
    
    On Fri, Apr 10, 2026 at 4:57 AM Dapeng Wang <wangdp20191008@gmail.com>
    wrote:
    
    > Lakshmi N <lakshmin.jhs@gmail.com> 于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
    
    >
    
  4. Re: Add missing CHECK_FOR_INTERRUPTS in autovacuum catalog scan loops

    Dapeng Wang <wangdp20191008@gmail.com> — 2026-04-11T12:19:55Z

    Lakshmi N <lakshmin.jhs@gmail.com> 于2026年4月11日周六 13:02写道:
    
    > Hi,
    >
    > On Fri, Apr 10, 2026 at 4:57 AM Dapeng Wang <wangdp20191008@gmail.com>
    > wrote:
    >
    >> Lakshmi N <lakshmin.jhs@gmail.com> 于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
    >
    
    
    Hi Lakshmi,
    
    The updated patch now covers all four catalog scan loops.
    Applies cleanly, compiles without warnings, and all 247
    regression tests pass.
    
    Regards,
    Dapeng Wang
    
  5. Re: Add missing CHECK_FOR_INTERRUPTS in autovacuum catalog scan loops

    Sami Imseih <samimseih@gmail.com> — 2026-04-11T20:10:42Z

    Hi,
    
    It was discussed [1] here if C_F_I is needed in these
    do_autovacuum/autovacuum_scores code paths, and it
    was decided not to add them.
    
    Also, at least on my tests with 100k evern with 1 million tables, I did
    not see a reason to do so. These are catalog scans that should
    happen quick enough, even in extreme cases, to not make
    this worthwhile.
    
    Others may have another opinion.
    
    --
    Sami
    
    
    [1] [https://www.postgresql.org/message-id/acwTxpz3Toxt0ty8%40nathan]