Thread

  1. Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE

    Pavel Stehule <pavel.stehule@gmail.com> — 2025-12-14T07:40:20Z

    Hi
    
    ne 14. 12. 2025 v 8:26 odesílatel Michael Paquier <michael@paquier.xyz>
    napsal:
    
    > On Wed, Oct 15, 2025 at 02:48:43AM +0000, Aya Iwata (Fujitsu) wrote:
    > > Thank you for your comments. I updated this patch to v0007.
    >
    > + * Exit the bgworker when its database is dropped, renamed, moved to a
    > + * different tablespace, or used as a template for CREATE DATABASE.
    >
    > I don't think that we need to list all these operations in details
    > here. We could just say "if its database is involved in a CREATE,
    > ALTER or DROP database command".  The docs should provide these
    > details, of course.
    >
    > +#define BGWORKER_EXIT_AT_DATABASE_CHANGE       0x0004
    >
    >
    I am checking this patch, and I think so used names can be little bit
    confusing
    
    BGWORKER_EXIT_AT_DATABASE_CHANGE - it is used for disconnecting workers on
    the template database, and this database is not changing.
    
    TerminateBgWorkersByDbOid - it doesn't terminate all workers, but only
    workers with some special flags
    
    Maybe BGWORKER_INTERRUPTABLE and TerminateInterruptableBgWorkersByDbOid ?
    
    Another question is if this cancellation should be implicit and should not
    require some special flag.
    
    When I want to disconnect connections to database when I do drop, I have to
    use FORCE flag
    
    So maybe there should be ALTER DATABASE ... RENAME ... FORCE - or if FORCE
    can terminare all workers (without special FLAG) ?
    
    Regards
    
    Pavel