pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix restart of interruptible bgworkers after database commands
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix restart of interruptible bgworkers after database commands
@ 2026-11-10 23:36 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Paquier @ 2026-11-10 23:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix restart of interruptible bgworkers after database commands

TerminateBackgroundWorkersForDatabase() sets the terminate flag of the
workers' slots, so the postmaster unregistered them regardless of
bgw_restart_time, even if the database command failed afterwards.

Let's signal the workers directly instead, like CountOtherDBBackends()
does for autovacuum workers, so that they are restarted based on
bgw_restart_time.  This gives the option for extension developers to
decide if an interruptible worker can be restarted or not, instead of
always been thrown away.  There can be an appeal in the restart if the
bgworker relies on a database to connect to coming from a GUC, if its
value can be reloaded.

Oversight in f1e251be80a0.

Author: Zsolt Parragi <zsolt.parragi@percona.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Aya Iwata <iwata.aya@jp.fujitsu.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/CAN4CZFNP+_aVsTqxfyNLU+AtRZMJeDRAR9XRfjPTwsWs3TXVaQ@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5bf919736b20ffdc8d646c33ed2d9054609b23ec

Modified Files
--------------
doc/src/sgml/bgworker.sgml                         |  6 ++--
src/backend/postmaster/bgworker.c                  | 32 +++++++++++++---------
.../modules/worker_spi/t/002_worker_terminate.pl   | 20 ++++++++++++--
src/test/modules/worker_spi/worker_spi--1.0.sql    |  3 +-
src/test/modules/worker_spi/worker_spi.c           |  4 ++-
5 files changed, 46 insertions(+), 19 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix restart of interruptible bgworkers after database commands
@ 2026-11-10 23:36 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Paquier @ 2026-11-10 23:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix restart of interruptible bgworkers after database commands

TerminateBackgroundWorkersForDatabase() sets the terminate flag of the
workers' slots, so the postmaster unregistered them regardless of
bgw_restart_time, even if the database command failed afterwards.

Let's signal the workers directly instead, like CountOtherDBBackends()
does for autovacuum workers, so that they are restarted based on
bgw_restart_time.  This gives the option for extension developers to
decide if an interruptible worker can be restarted or not, instead of
always been thrown away.  There can be an appeal in the restart if the
bgworker relies on a database to connect to coming from a GUC, if its
value can be reloaded.

Oversight in f1e251be80a0.

Author: Zsolt Parragi <zsolt.parragi@percona.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Aya Iwata <iwata.aya@jp.fujitsu.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/CAN4CZFNP+_aVsTqxfyNLU+AtRZMJeDRAR9XRfjPTwsWs3TXVaQ@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1a561b3484c05b9f1b4cf4f76370cc32b3ef48ae

Modified Files
--------------
doc/src/sgml/bgworker.sgml                         |  6 ++--
src/backend/postmaster/bgworker.c                  | 32 +++++++++++++---------
.../modules/worker_spi/t/002_worker_terminate.pl   | 20 ++++++++++++--
src/test/modules/worker_spi/worker_spi--1.0.sql    |  3 +-
src/test/modules/worker_spi/worker_spi.c           |  4 ++-
5 files changed, 46 insertions(+), 19 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-11-10 23:36 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 23:36 pgsql: Fix restart of interruptible bgworkers after database commands Michael Paquier <michael@paquier.xyz>
2026-11-10 23:36 pgsql: Fix restart of interruptible bgworkers after database commands Michael Paquier <michael@paquier.xyz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox