apt-get not RFC6555 (Happy Eyeballs) compliant

Bug #1308200 reported by Sander Jonkers
46
This bug affects 8 people
Affects Status Importance Assigned to Milestone
apt (Debian)
Fix Released
Unknown
apt (Ubuntu)
Fix Released
Medium
Julian Andres Klode

Bug Description

Disclaimer: I'm not sure if this is a bug, or a feature. If it is not a bug, I think reporting this issue is useful anyway because it causes long delays in apt-get install / apt-get update.

On dual-stack setups (IPv4 and IPv6), if one of the two paths is slow or non-functional at all, the overall application experience can be slow.

An application that uses a Happy Eyeballs (RFC 6555) algorithm checks both IPv4 and IPv6 connectivity (with a preference for IPv6) and uses the first connection that is returned. This has been implemented in, for example, Chrome and Firefox.

apt / apt-get does not have this functionality. Due to this lack, a apt-get run can be very slow: a "sudo apt-get update" can take up to 15 minutes on a system with a non-functional IPv6 connection, even if the system is already uptodate, which normally only takes 15 seconds or so.

"man apt.conf" shows this info:

       ForceIPv4
           When downloading, force to use only the IPv4 protocol.

       ForceIPv6
           When downloading, force to use only the IPv6 protocol.

So no feature "RFC6555" or "HappyEyeballs".

An ugly work-around is this: Create a file /etc/apt/apt.conf.d/99timeout with these contents

Acquire::http::Timeout "2";
Acquire::ftp::Timeout "2";

That way, after 2 seconds the other path is chosen.

$ lsb_release -rd
Description: Ubuntu 14.04 LTS
Release: 14.04

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: apt 1.0.1ubuntu2
ProcVersionSignature: Ubuntu 3.13.0-24.46-generic 3.13.9
Uname: Linux 3.13.0-24-generic x86_64
ApportVersion: 2.14.1-0ubuntu2
Architecture: amd64
CurrentDesktop: Unity
Date: Tue Apr 15 20:26:25 2014
InstallationDate: Installed on 2014-04-10 (4 days ago)
InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Daily amd64 (20140410)
SourcePackage: apt
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Sander Jonkers (jonkers) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in apt (Ubuntu):
status: New → Confirmed
Changed in apt (Ubuntu):
importance: Undecided → Low
importance: Low → Medium
status: Confirmed → In Progress
assignee: nobody → Julian Andres Klode (juliank)
Changed in apt (Debian):
status: Unknown → New
Revision history for this message
Julian Andres Klode (juliank) wrote :

Spent the day implementing a subset of Happy Eyeballs Version 2 (RFC 8305, https://tools.ietf.org/html/rfc8305) for APT. I initially started implementing a subset of its predecessor (RFC 6555, https://tools.ietf.org/html/rfc6555) half a year ago and reworked that today, but then I noticed the new RFC and switched to that.

The branch pu/happy-eyeballs2a (https://github.com/Debian/apt/compare/master...julian-klode:pu/happy-eyeballs2a?expand=1) implements it as following:

1. All addresses returned by getaddrinfo() are ordered so that preferred and non-prefered address families alternate (for example, IPv6, IPv4, IPv6, IPv4).
2. For each address, we attempt a connection and wait 250 ms for it and all previous attempts, storing all attempts in a list (vector currently). If one connection succeeds it is used.
3. If no connection succeeded, we wait another TimeOut for all attempts and use the result of that wait as the final result.

This means we easily fall back in cases of broken IPv6 routing, and also in situations where some hosts just refuse connections.

Revision history for this message
Julian Andres Klode (juliank) wrote :

Fixed in the Git repository. This will be part of 1.6~alpha6 very shortly

You can see the commit message below, and you can check the diff of the fix at:

    https://anonscm.debian.org/cgit/apt/apt.git/diff/?id=3bbd328
---
commit 3bbd328396745d0dd6c5585935040082a2c41e3e
Author: Julian Andres Klode <email address hidden>
Date: Tue Jan 2 22:15:50 2018 +0100

    Add rapid "happy eyeballs" connection fallback (RFC 8305)

    Try establishing connections in alternating address families in
    rapid intervals of 250 ms, adding more connections to the wait
    list until one succeeds (RFC 8305, happy eyeballs 2).

    It is important that WaitAndCheckErrors() waits until it has
    a successful connection, a time out, or all connections failed
    - otherwise the timing between tries might be wrong, and the
    final long wait might exit early because one connection failed
    without trying the others. Timing wise, this only works correctly
    on Linux, as select() counts down there. But we rely on that in
    some other places too, so this is not the time to fix that.

    Timeouts are only reported in the final long wait - the short
    inner waits are expected to time out more often, and multiple
    times, we do not want to report them.

    Closes: #668948
    LP: #1308200
    Gbp-Dch: paragraph

Changed in apt (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Julian Andres Klode (juliank) wrote :

Released upstream as 1.6~alpha6, should sync tomorrow I think.

Changed in apt (Debian):
status: New → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apt - 1.6~alpha7ubuntu1

---------------
apt (1.6~alpha7ubuntu1) bionic; urgency=medium

  * Try to work around test-method-mirror failure by setting umask at start

 -- Julian Andres Klode <email address hidden> Wed, 31 Jan 2018 12:19:58 +0100

Changed in apt (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.