Fix DROP DATABASE FORCE failing on parallel autovacuum workers. An autovacuum worker advertises no role in its PGPROC, but its parallel workers advertise the bootstrap superuser. So DROP DATABASE ... FORCE run by a non-superuser with pg_signal_backend failed with "permission denied to terminate process" while a parallel autovacuum was running in the database, although the same user can terminate the autovacuum worker itself, and DROP DATABASE without FORCE succeeds.
Fix by checking a parallel worker against its leader's role when the leader advertises no role. The leader is in the same database and is checked too, so this doesn't let anyone terminate a process they couldn't already terminate through its leader. Parallel workers launched by a background worker connected without a user name have had the same problem in older branches, but we haven't received any report of it, and the next minor release is the final one for v14, leaving no chance to fix a mistake there. So backpatch only to v19, where parallel autovacuum made the problem easy to hit. If we get a report, we can backpatch it further. Found by Bharath using AI assisted review. Reported-by: Bharath Rupireddy <[email protected]> Author: Bharath Rupireddy <[email protected]> Reviewed-by: Masahiko Sawada <[email protected]> Reviewed-by: shihao zhong <[email protected]> Discussion: https://postgr.es/m/CALj2ACWK6PkOk5MTfibtJyTYpb=Aq_8=yaexnpkhoj11boc...@mail.gmail.com Backpatch-through: 19 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/a39e53a700c5b728f2f7dab964e33b157979fb3a Modified Files -------------- src/backend/commands/vacuumparallel.c | 4 +++ src/backend/storage/ipc/procarray.c | 25 ++++++++++--- .../test_autovacuum/t/001_parallel_autovacuum.pl | 42 ++++++++++++++++++++++ 3 files changed, 67 insertions(+), 4 deletions(-)
