Free port choosing freezes when PostgresNode::use_tcp is used on BSD systems
Alexey Kondratov <a.kondratov@postgrespro.ru>
From: Alexey Kondratov <a.kondratov@postgrespro.ru>
To: pgsql-hackers@lists.postgresql.org
Date: 2021-04-19T22:22:41Z
Lists: pgsql-hackers
Attachments
- patch_PostgresNode.diff (text/x-diff) patch
- reproduce.diff (text/x-diff) patch
Hi Hackers, Inside PostgresNode.pm there is a free port choosing routine --- get_free_port(). The comment section there says: # On non-Linux, non-Windows kernels, binding to 127.0.0/24 addresses # other than 127.0.0.1 might fail with EADDRNOTAVAIL. And this is an absolute true, on BSD-like systems (macOS and FreeBSD tested) it hangs on looping through the entire ports range over and over when $PostgresNode::use_tcp = 1 is set, since bind fails with: # Checking port 52208 # bind: 127.0.0.1 52208 # bind: 127.0.0.2 52208 bind: Can't assign requested address To reproduce just apply reproduce.diff and try to run 'make -C src/bin/pg_ctl check'. This is not a case with standard Postgres tests, since TestLib.pm chooses unix sockets automatically everywhere outside Windows. However, we got into this problem when tried to run a custom tap test that required TCP for stable running. That way, if it really could happen why not to just skip binding to 127.0.0/24 addresses other than 127.0.0.1 outside of Linux/Windows as per attached patch_PostgresNode.diff? Regards -- Alexey Kondratov Postgres Professional https://www.postgrespro.com Russian Postgres Company
Commits
-
Add TABLESPACE option to REINDEX
- c5b286047cd6 14.0 landed
-
Refactor code in tablecmds.c to check and process tablespace moves
- 4c9c359d38ff 14.0 landed
-
Refactor option handling of CLUSTER, REINDEX and VACUUM
- a3dc926009be 14.0 landed
-
pg_dump: Don't use enums for defining bit mask values
- d2a2808eb444 14.0 landed
-
Refactor CLUSTER and REINDEX grammar to use DefElem for option lists
- b5913f612079 14.0 landed
-
Refactor parsing rules for option lists of EXPLAIN, VACUUM and ANALYZE
- 873ea9ee692e 14.0 landed
-
Improve tab completion of REINDEX in psql
- 1f75b454134c 14.0 landed
-
Fix possible crash during FATAL exit from reindexing.
- d12bdba77b0f 13.0 cited