Skip to content

Commit b92d8e5

Browse files
zhan7236baobao0206
authored andcommitted
fix(backend): Skip cdb_setup/cdb_cleanup for auxiliary background workers
Fix issue apache#1389: Auxiliary processes (ftsprobe, global deadlock detector, dtx recovery, sweeper, pg_cron launcher) currently open unnecessary network sockets for interconnect communication they don't need. Per review feedback, instead of adding checks inside cdb_setup/cdb_cleanup functions, skip calling these functions entirely for auxiliary background workers in InitPostgres(). This resolves the security concern of having unnecessary open network ports and reduces resource usage.
1 parent 8f0f276 commit b92d8e5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/backend/utils/init/postinit.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,8 +1422,14 @@ InitPostgres(const char *in_dbname, Oid dboid,
14221422
* Primary function is to establish connections to the qExecs.
14231423
* This is SKIPPED when the database is in bootstrap mode or
14241424
* Is not UnderPostmaster.
1425+
*
1426+
* Also skip for auxiliary background workers (e.g., ftsprobe, global
1427+
* deadlock detector, dtx recovery, sweeper, pg_cron launcher). These
1428+
* processes don't require interconnect for data exchange and opening
1429+
* unnecessary network sockets may be considered a security issue.
14251430
*/
1426-
if (!bootstrap && IsUnderPostmaster && !IsLoginMonitorWorkerProcess())
1431+
if (!bootstrap && IsUnderPostmaster && !IsLoginMonitorWorkerProcess() &&
1432+
!amAuxiliaryBgWorker())
14271433
{
14281434
cdb_setup();
14291435
on_proc_exit( cdb_cleanup, 0 );

0 commit comments

Comments
 (0)