Free port choosing freezes when PostgresNode::use_tcp is used on BSD systems

From: Alexey Kondratov <a(dot)kondratov(at)postgrespro(dot)ru>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Free port choosing freezes when PostgresNode::use_tcp is used on BSD systems
Date: 2021-04-19 22:22:41
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Hackers,

Inside 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 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: 52208
# bind: 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
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 outside of Linux/Windows as
per attached patch_PostgresNode.diff?

Alexey Kondratov

Postgres Professional
Russian Postgres Company

Attachment Content-Type Size
patch_PostgresNode.diff text/x-diff 486 bytes
reproduce.diff text/x-diff 467 bytes

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Dan Lynch 2021-04-19 22:33:52 column-level security policies for application users
Previous Message Tom Lane 2021-04-19 22:09:51 Re: "could not find pathkey item to sort" for TPC-DS queries 94-96