Skip to content

Commit 9210269

Browse files
zhan7236gfphoenix78
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 0d23be8 commit 9210269

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
@@ -1267,8 +1267,14 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
12671267
* Primary function is to establish connections to the qExecs.
12681268
* This is SKIPPED when the database is in bootstrap mode or
12691269
* Is not UnderPostmaster.
1270+
*
1271+
* Also skip for auxiliary background workers (e.g., ftsprobe, global
1272+
* deadlock detector, dtx recovery, sweeper, pg_cron launcher). These
1273+
* processes don't require interconnect for data exchange and opening
1274+
* unnecessary network sockets may be considered a security issue.
12701275
*/
1271-
if (!bootstrap && IsUnderPostmaster && !IsLoginMonitorWorkerProcess())
1276+
if (!bootstrap && IsUnderPostmaster && !IsLoginMonitorWorkerProcess() &&
1277+
!amAuxiliaryBgWorker())
12721278
{
12731279
cdb_setup();
12741280
on_proc_exit( cdb_cleanup, 0 );

0 commit comments

Comments
 (0)