Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 926221 - emerge --getbinpkg hangs for a long time when binhost is unresponsive
Summary: emerge --getbinpkg hangs for a long time when binhost is unresponsive
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Binary packages support (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on: 925481
Blocks:
  Show dependency tree
 
Reported: 2024-03-05 20:25 UTC by Alexey
Modified: 2024-04-28 00:32 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey 2024-03-05 20:25:49 UTC
sys-apps/portage-3.0.61-r1:0

My ISP today broke IPv6, so I have an address, but it doesn't route.

Any emerge invocation, even as simple as `emerge -avp --getbinpkg vim` gets stuck without outputting anything, with 0 CPU usage.

`strace -p` shows that it's blocked on: connect(3, {sa_family=AF_INET6, sin6_port=htons(443), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "2001:41c8:20:5e6::150", &sin6_addr), sin6_scope_id=0}, 28

That IP is the binhost I configured in /etc/portage/binrepos.conf/gentoobinhost.conf as `sync-uri = https://mirror.bytemark.co.uk/gentoo/releases/amd64/binpackages/17.1/x86-64-v3/`. 

Removing --getbinpkg from EMERGE_DEFAULT_OPTS fixes portage. It should time out the connection attempt correctly if can't connect.
Comment 1 Mike Gilbert gentoo-dev 2024-03-05 20:40:02 UTC
Please send SIGUSR1 to the emerge process to trigger the Python debugger. Then enter "bt" to obtain a call trace.
Comment 2 Alexey 2024-03-05 20:42:04 UTC
(Pdb) bt
  /usr/lib/python-exec/python3.11/emerge(88)<module>()
-> main()
  /usr/lib/python-exec/python3.11/emerge(57)main()
-> retval = emerge_main()
  /usr/lib/python3.11/site-packages/_emerge/main.py(1308)emerge_main()
-> return run_action(emerge_config)
  /usr/lib/python3.11/site-packages/_emerge/actions.py(3479)run_action()
-> mytrees["bintree"].populate(
  /usr/lib/python3.11/site-packages/portage/dbapi/bintree.py(934)populate()
-> self._populate_remote(
  /usr/lib/python3.11/site-packages/portage/dbapi/bintree.py(1435)_populate_remote()
-> f = _urlopen(
  /usr/lib/python3.11/site-packages/portage/util/_urlopen.py(62)urlopen()
-> hdl = opener.open(request)
  /usr/lib/python3.11/urllib/request.py(519)open()
-> response = self._open(req, data)
  /usr/lib/python3.11/urllib/request.py(536)_open()
-> result = self._call_chain(self.handle_open, protocol, protocol +
  /usr/lib/python3.11/urllib/request.py(496)_call_chain()
-> result = func(*args)
  /usr/lib/python3.11/urllib/request.py(1391)https_open()
-> return self.do_open(http.client.HTTPSConnection, req,
  /usr/lib/python3.11/urllib/request.py(1348)do_open()
-> h.request(req.get_method(), req.selector, req.data, headers,
  /usr/lib/python3.11/http/client.py(1298)request()
-> self._send_request(method, url, body, headers, encode_chunked)
  /usr/lib/python3.11/http/client.py(1344)_send_request()
-> self.endheaders(body, encode_chunked=encode_chunked)
  /usr/lib/python3.11/http/client.py(1293)endheaders()
-> self._send_output(message_body, encode_chunked=encode_chunked)
  /usr/lib/python3.11/http/client.py(1052)_send_output()
-> self.send(msg)
  /usr/lib/python3.11/http/client.py(990)send()
-> self.connect()
  /usr/lib/python3.11/http/client.py(1463)connect()
-> super().connect()
  /usr/lib/python3.11/http/client.py(956)connect()
-> self.sock = self._create_connection(
  /usr/lib/python3.11/socket.py(836)create_connection()
-> sock.connect(sa)
> /usr/lib/python-exec/python3.11/emerge(28)debug_signal()->None
-> pdb.set_trace()
Comment 3 Mike Gilbert gentoo-dev 2024-03-05 22:35:33 UTC
Looks like we could add a timeout parameter to the urlopen calls in portage.util._urlopen.
Comment 4 Mike Gilbert gentoo-dev 2024-03-06 03:44:34 UTC
So I just tried to reproduce this by black-holing an IPv6 address using nftables. 

It was a long wait, but after about 2 minutes, the following output was produced:

!! Error fetching binhost package info from 'http://[2001:xxxx:xxxx:xxxx::69]'
!!! <urlopen error [Errno 110] Connection timed out>

When not configured explicitly, the kernel has a default connection timeout.
Comment 5 Larry the Git Cow gentoo-dev 2024-03-07 20:42:41 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=b7e89f866a9a1d73ab72670d74e2292b05893849

commit b7e89f866a9a1d73ab72670d74e2292b05893849
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2024-03-06 04:01:27 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2024-03-06 18:19:31 +0000

    util: set a timeout for urlopen calls
    
    A hung urlopen call can cause emerge to produce no output when fetching
    binhost data.
    
    Bug: https://bugs.gentoo.org/926221
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 lib/portage/util/_urlopen.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 6 Larry the Git Cow gentoo-dev 2024-04-28 00:32:39 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f1e53b9368c215451e3af78b557d8b86a2db9677

commit f1e53b9368c215451e3af78b557d8b86a2db9677
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-04-28 00:31:29 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-04-28 00:31:29 +0000

    sys-apps/portage: add 3.0.64
    
    Closes: https://bugs.gentoo.org/925481
    Closes: https://bugs.gentoo.org/675748
    Closes: https://bugs.gentoo.org/712222
    Closes: https://bugs.gentoo.org/920330
    Closes: https://bugs.gentoo.org/925213
    Closes: https://bugs.gentoo.org/925863
    Closes: https://bugs.gentoo.org/925888
    Closes: https://bugs.gentoo.org/925907
    Closes: https://bugs.gentoo.org/926048
    Closes: https://bugs.gentoo.org/926221
    Closes: https://bugs.gentoo.org/927059
    Closes: https://bugs.gentoo.org/927632
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.64.ebuild | 242 +++++++++++++++++++++++++++++++++
 2 files changed, 243 insertions(+)