Hi, While investigating a customer issue it's turned out that if a parallel worker executes inet_server_addr() and inet_server_port() the results are always null because MyProcPort is not set in parallel workers. We can reproduce it in all supported versions higher than 9.6. Here is an example:
postgres=# select inet_server_addr(), inet_server_port(); inet_server_addr | inet_server_port ------------------+------------------ 172.254.99.88 | 5432 (1 row) postgres=# select inet_client_addr(), inet_client_port(); inet_client_addr | inet_client_port ------------------+------------------ 172.254.99.109 | 31383 (1 row) postgres=# set force_parallel_mode to on; SET postgres=# select inet_server_addr(), inet_server_port(); inet_server_addr | inet_server_port ------------------+------------------ | (1 row) postgres=# select inet_client_addr(), inet_client_port(); inet_client_addr | inet_client_port ------------------+------------------ 172.254.99.109 | 31383 (1 row) To fix this issue, I think there are two options: 1. Inherits the local address information from postmaster or the leader to parallel workers. 2. Have both inet_server_addr() and inet_server_port() parallel restricted. Since auxiliary processes including parallel workers don't communicate directly to the client, this information is basically not necessary. Also, the option #1 needs code change to pass the information, which brings complexity and is not good in terms of back-patching. So I'd prefer the option #2. I've attached the patch doing the option #2. Regards, -- Masahiko Sawada EnterpriseDB: https://www.enterprisedb.com/
fix_inet_server_addr_port.patch
Description: Binary data