apt repository disk format has race conditions
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| | APT |
Fix Released
|
Undecided
|
Unassigned | |
| | apt (Ubuntu) |
Medium
|
Unassigned | ||
Bug Description
Apt archives are accessed over HTTP; this has resulted in a cluster of bugs (reported here, and upstream) about problems behind intercepting caches, problems with squid etc.
There are 3 interlocking issues:
A - mirror networks may be out of sync with each other (e.g. a file named on one mirror may no longer exist, or may not yet exist, on another mirror)
B - updating files on a single mirror is not atomic - and even small windows of inconsistency will, given enough clients, cause headaches.
C - caches exacerbate race conditions - when one happens, until the cached data expires, all clients of the cache will suffer from the race
Solving this requires one of several things:
- file system transactions
- an archive format that requires only weakly ordered updates to the files at particular urls with the assumption that only one file may be observed to change at a time (because a lookup of file A, then B, may get a cache miss on A and a cache hit on B, so even if all clients strictly go A, then B, updates may still see old files when paths are reused).
- super robust clients that repeatedly retry with progressively less cache friendly headers until they have a consistent view. (This is very tricky to do).
It may be possible to do a tweak to the apt repository format though, which would allow publishing a race-free format in parallel with the existing layout, while clients migrate. To be safe against issue (A) the mirror network would need some care around handling of dns round-robin mirrors [to minimise the situation where referenced data is not available], but this should be doable - or alternatively clients doing 'apt-get update' may need to be willing to retry to accommodate round-robin skew.
What would such an archive format look like?
It would have only one well known file name (InRelease), which would be internally signed. Rather than signing e.g. Packages.gz, it would sign a uniquely named packages and sources file - e.g. Packages-$HASH.gz or Packages-
Backwards compatibility is achieved by using the same filenames for deb's and the like. We need to keep writing Packages.gz though, and Releases, until we no longer worry about old apt clients. We can optimise disk space a little by making Packages.gz a symlink to a Packages-$HASH.gz (and so on for Sources..), but it may be simpler and less prone to unexpected behaviour to keep using regular files.
tl;dr
* Unique file names for all unique file content with one exception
* InRelease, a self-signed file that provides hashes and names the index files (Packages, Sources, Translations etc)
* Coexists with existing archive layout
Related bugs:
* bug 804252: Please support InRelease files
* bug 1430011: support apt by-hash mirrors
| Changed in apt (Ubuntu): | |
| importance: | Undecided → Medium |
| Robie Basak (racb) wrote : | #2 |
A related bug is bug 214612 (pdiff support in the repository).
| Scott Moser (smoser) wrote : | #3 |
This is being discussed at: http://
| David Kalnischkies (donkult) wrote : | #4 |
In the meantime - as it is fairly obvious that this will not be done instantly and unlikely to be in time for q-freezes - you might want to explore solutions similar to bittorrent which are available today with apt-p2p or apt-transport-
Either doesn't solve all problems, but should be able to fix at least a few for now.
| information type: | Public → Public Security |
| information type: | Public Security → Public |
The following does not solve the problem, but limits the frequency of the problems when using squid as a proxy. I added the following two lines to the squid configuration:
---
acl DEBIAN_NOCACHE urlpath_regex Release Packages.bz2 Translation.*.bz2
cache deny DEBIAN_NOCACHE
---
This prevents the files that change frequently from being cached by squid. As they are relatively small, the impact on the bandwidth use is not that bad.
It does not solve the problem with mirrors being temporarily out of sync or the race condition in file access.
| Changed in apt (Ubuntu): | |
| status: | Confirmed → New |
| Launchpad Janitor (janitor) wrote : | #6 |
Status changed to 'Confirmed' because the bug affects multiple users.
| Changed in apt (Ubuntu): | |
| status: | New → Confirmed |
| Christian Reis (kiko) wrote : | #7 |
We had a report of a MAAS user yesterday with this issue affecting some of his deployments. He was not behind a proxy. He retried the deployment and it worked, but we'd like to avoid sporadic failures as much as possible so this would be nice to see addressed.
| Michael Vogt (mvo) wrote : | #8 |
Fwiw, we have support for the by-hash scheme in apt in experimetnal:
https:/
| Scott Moser (smoser) wrote : | #9 |
Per mvo, there is apparently by-hash support in debian experimental with some references seen at
https:/
| Scott Moser (smoser) wrote : | #10 |
relevant changelog in debian:
* Implement simple by-hash for apt update to improve reliability of
the update. Apt will try to fetch the Packages file via
/by-
- add APT::Acquire:
- add Acquire-By-Hash=1 to Release file
| Scott Moser (smoser) wrote : | #11 |
I opened bug 1430011 as a request for launchpad to gain the ability to create /populate by-hash mirrors.
| Christian Brandt (brandtc) wrote : | #12 |
Just some rough observations, I am using a visible Proxy configures through /etc/apt/ and also HTTP_PROXY running on "http://
I have the odd feeling that the de mirror is just exceptional erratic.
Why am I using a caching proxy? Because it speeds up updating and installing while using multiple clients (once had more than 100 after one 2MBit line, right now still five). There is little need to cache lists, indexes, hashes, keys and so on, I am only interested in caching the deb Files so maybe there is some workaround to ease the strain on the proxy?
| no longer affects: | maas |
| description: | updated |
| description: | updated |
| Dapxitlo (nhducit) wrote : | #13 |
affect to me too
| Dapxitlo (nhducit) wrote : | #14 |
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
E: Some index files failed to download. They have been ignored, or old ones used instead.
| quequotion (quequotion) wrote : | #15 |
Is there any aspect of deb package management that isn't broken?
| sunil (suneel) wrote : | #16 |
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
W: Failed to fetch http://
| Francois Leurent (fleurent) wrote : | #17 |
Instead of whipping /var/lib/apt/list, i found out that touch -t 1501010000 /var/lib/
| michael jones (bcmalloy) wrote : | #18 |
mike@mike-desktop ~ $ sudo apt-get update
[sudo] password for mike:
Ign http://
Ign http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Ign http://
Hit http://
Hit http://
Get:1 http://
Hit http://
Hit http://
Ign http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Get:2 http://
Hit http://
Get:3 http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Get:4 http://
| Scott Moser (smoser) wrote : | #19 |
Given the availability of by-hash, this is not really 'apt's problem any more.
The changes left to be forever rid of 'hash sum mismatch' is to fix bug 1430011
| Changed in apt: | |
| status: | New → Fix Released |
| Changed in apt (Ubuntu): | |
| status: | Confirmed → Fix Released |
| Abhijith Gururaj (abhiithgururaj) wrote : | #20 |
Hi I am still facing this problem . here is my console output:
sudo apt-get upgrade --fix-missing
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
gir1.2-
4.0-18 libwebkit2gtk-
libwebkit2gtk-
5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 8,650 kB/23.3 MB of archives.
After this operation, 3,997 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://
libwebkit2gtk-
Err:1 http://
libwebkit2gtk-
Hash Sum mismatch
Get:1 http://
libwebkit2gtk-
Err:1 http://
libwebkit2gtk-
Hash Sum mismatch
Fetched 17.3 MB in 13s (1,266 kB/s)
E: Failed to fetch http://
How to fix this?
| Julian Andres Klode (juliank) wrote : | #21 |
Switch to a different mirror. Hash sum mismatches on .deb file should not happen on any well-built mirror.
| Abhijith Gururaj (abhiithgururaj) wrote : | #22 |
@juliank I have configured the updater to use the main server. Downloading updates from the main server shouldn't cause such errors, right?
On Thu, Jun 01, 2017 at 07:20:18AM -0000, Abhijith Gururaj wrote:
> @juliank I have configured the updater to use the main server.
> Downloading updates from the main server shouldn't cause such errors,
> right?
Some ISPs intercept their clients' downloads. The error is telling you
that the download appears to have been modified in transit, so isn't
safe to install. It cannot tell you why or where that happened,
unfortunately.
This bug was to track a known case of an index file appearing to have
been modified in transit due to a known race condition. That issue was
fixed, and it seems unlikely to me that you are affected by that
particular issue as your mismatch is on deb and not an index file.
If you need help, you're more likely to get it from a place dedicated to
that, since few people follow this particular bug. See
http://
| the835t (the835t) wrote : | #24 |
affects me too


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