From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Executing inet_server_addr/port() in parallel workers |
Date: | 2021-01-12 12:33:38 |
Message-ID: | CAD21AoAT4aHP0Uxq91qpD7NL009tnUYQe-b14R3MnSVOjtE71g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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/
Attachment | Content-Type | Size |
---|---|---|
fix_inet_server_addr_port.patch | application/octet-stream | 967 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiko Sawada | 2021-01-12 12:40:53 | Re: Key management with tests |
Previous Message | torikoshia | 2021-01-12 12:21:18 | Re: Get memory contexts of an arbitrary backend process |