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 <[email protected]> Author: Michael Paquier <[email protected]> Reviewed-by: Aya Iwata <[email protected]> Reviewed-by: Xuneng Zhou <[email protected]> Discussion: https://postgr.es/m/can4czfnp+_avstqxfynlu+atrzmjedrar9xrfjptwsws3tx...@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(-)
