Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lYcI5-0001t0-EY for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Apr 2021 22:22:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lYcI3-0003Wh-Jc for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Apr 2021 22:22:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lYcI3-0003Wa-Au for pgsql-hackers@lists.postgresql.org; Mon, 19 Apr 2021 22:22:47 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lYcHy-0001Cf-SY for pgsql-hackers@lists.postgresql.org; Mon, 19 Apr 2021 22:22:46 +0000 Received: from mail.postgrespro.ru (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id C186B21C7F5E for ; Tue, 20 Apr 2021 01:22:41 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1618870961; bh=BVJmYBNNjFfrlGlAve28XhIy9i0Sey0ebMGOmAq7XtI=; h=Date:From:To:Subject:In-Reply-To:References; b=iL73qkMQehMzZuoWDtqbbIAnopY1jWMJXB4P/X0yrFkjAxF+8pPzDSH82vPXsHqL/ UcjOg2M0BPFC4QbCQ3FFB1J6XXzbE+sJcmdVAKAd4uboOVmwVhHcnmWEd3YbauWPHT CzjmYOlDKaq2M9kmDsQSbEyhCC9rsH88ljUeUkJU= MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_14ea214a196d270d5769e38617882c85" Content-Transfer-Encoding: 7bit Date: Tue, 20 Apr 2021 01:22:41 +0300 From: Alexey Kondratov To: pgsql-hackers@lists.postgresql.org Subject: Free port choosing freezes when PostgresNode::use_tcp is used on BSD systems In-Reply-To: <66bad38beb87fb32952d89602e467444@postgrespro.ru> References: <20210127213658.GA736@alvherre.pgsql> <55c6c1526b94d2caf54c33262fe00674@postgrespro.ru> <1c506564e2a732ec17790bd8c34f042e@postgrespro.ru> <66bad38beb87fb32952d89602e467444@postgrespro.ru> User-Agent: Roundcube Webmail/1.4.0 Message-ID: <82e271a9a11928337fcb5b5e57b423c0@postgrespro.ru> X-Sender: a.kondratov@postgrespro.ru List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=_14ea214a196d270d5769e38617882c85 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed 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 --=_14ea214a196d270d5769e38617882c85 Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=patch_PostgresNode.diff Content-Disposition: attachment; filename=patch_PostgresNode.diff; size=486 ZGlmZiAtLWdpdCBhL3NyYy90ZXN0L3BlcmwvUG9zdGdyZXNOb2RlLnBtIGIvc3JjL3Rlc3QvcGVy bC9Qb3N0Z3Jlc05vZGUucG0KaW5kZXggZGI0N2E5N2QxOTYuLjlhZGQ5YmRlMmE0IDEwMDY0NAot LS0gYS9zcmMvdGVzdC9wZXJsL1Bvc3RncmVzTm9kZS5wbQorKysgYi9zcmMvdGVzdC9wZXJsL1Bv c3RncmVzTm9kZS5wbQpAQCAtMTIwMyw3ICsxMjAzLDcgQEAgc3ViIGdldF9mcmVlX3BvcnQKIAkJ aWYgKCRmb3VuZCA9PSAxKQogCQl7CiAJCQlmb3JlYWNoIG15ICRhZGRyIChxdygxMjcuMC4wLjEp LAotCQkJCSR1c2VfdGNwID8gcXcoMTI3LjAuMC4yIDEyNy4wLjAuMyAwLjAuMC4wKSA6ICgpKQor CQkJCSR1c2VfdGNwICYmICgkXk8gZXEgImxpbnV4IiB8fCAkVGVzdExpYjo6d2luZG93c19vcykg PyBxdygxMjcuMC4wLjIgMTI3LjAuMC4zIDAuMC4wLjApIDogKCkpCiAJCQl7CiAJCQkJaWYgKCFj YW5fYmluZCgkYWRkciwgJHBvcnQpKQogCQkJCXsK --=_14ea214a196d270d5769e38617882c85 Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=reproduce.diff Content-Disposition: attachment; filename=reproduce.diff; size=467 ZGlmZiAtLWdpdCBhL3NyYy9iaW4vcGdfY3RsL3QvMDAxX3N0YXJ0X3N0b3AucGwgYi9zcmMvYmlu L3BnX2N0bC90LzAwMV9zdGFydF9zdG9wLnBsCmluZGV4IGIxZTQxOWYwMmU5Li5jMjVjMDc5MzUz NyAxMDA2NDQKLS0tIGEvc3JjL2Jpbi9wZ19jdGwvdC8wMDFfc3RhcnRfc3RvcC5wbAorKysgYi9z cmMvYmluL3BnX2N0bC90LzAwMV9zdGFydF9zdG9wLnBsCkBAIC0xMSw2ICsxMSw4IEBAIHVzZSBU ZXN0OjpNb3JlIHRlc3RzID0+IDI0OwogbXkgJHRlbXBkaXIgICAgICAgPSBUZXN0TGliOjp0ZW1w ZGlyOwogbXkgJHRlbXBkaXJfc2hvcnQgPSBUZXN0TGliOjp0ZW1wZGlyX3Nob3J0OwogCiskUG9z dGdyZXNOb2RlOjp1c2VfdGNwID0gMTsKKwogcHJvZ3JhbV9oZWxwX29rKCdwZ19jdGwnKTsKIHBy b2dyYW1fdmVyc2lvbl9vaygncGdfY3RsJyk7CiBwcm9ncmFtX29wdGlvbnNfaGFuZGxpbmdfb2so J3BnX2N0bCcpOwo= --=_14ea214a196d270d5769e38617882c85--