Chris,

Thanks for your continued detailed reporting.

The short answer -- I am glad it fixes it and I will clean up the patches and
queue them for the next release.

I'll try to answer your detailed questions below.

On Sun, Oct 15, 2017 at 01:04:36AM +0200, [email protected] wrote:

> What exactly do you mean with by-hash files, perhaps the dep11_by-hash files
> in /var/cache/apt-cacher/package (I had them before, see above output of
> -v)?

A couple of years ago APT started to include support for distributing index
files named by their MD5/SHA256 hash to prevent the regular 'Hash sum mismatch'
error that we used to see regularly when index files and caches were out of
sync. See https://wiki.debian.org/RepositoryFormat#Acquire-By-Hash

> Why do you have files which I don't have?

Probably because I have multiple clients using apt-cacher with different
releases. Also, in your original report you suggested you had deleted
/var/cache/apt-cacher and recreated it a some point. So files that may have been
cached initially would have been lost.

> Do I have to configure
> something special in /etc/apt/apt.conf.d/x for that? The only option I can
> imagine is that I have disabled caching of packages in
> /var/cache/apt/archives, as the packages are cached centrally by apt-cacher
> anyway. However, I do not think this is related.

Neither do I.

> $ ls -la /var/cache/apt-cacher/packages
> drwxr-xr-x 2 www-data www-data   4096 Okt 14 23:16 .
> drwxr-xr-x 6 www-data www-data   4096 Okt 10 19:31 ..
> -rw-r--r-- 1 www-data www-data 135616 Okt 14 23:16 
> ftp.de.debian.org_debian_dists_testing_InRelease
> -rw-r--r-- 1 www-data www-data  25494 Okt 14 23:16 
> security.debian.org_dists_testing_updates_InRelease
> 
> The following was necessary, as otherwise only the two above files were
> downloaded.
> 
> $ rm -rf /var/cache/apt/*cache.bin
> $ apt-get update

This seems fine: you had recently updated therefore there were no new files
requested or cached. By deleting /var/cache/apt/*cache.bin you forced apt to
fetch new index files through apt-cacher.
 
> Today, as I already have installed all upgrades in the morning, I perform an
> install of an arbitrary package and not a dist-uprade here. However, this
> should make no difference.
> 
> $ apt-get install aria2
 
[snip]

> $ /tmp/apt-cacher-cleanup-double-patched.pl -v
> Invoked as root, changing to www-data:www-data and re-execing.
> Checking for 
> ftp.de.debian.org_debian_dists_testing_main_binary-amd64_Packages{,.gz,.xz,.bz2}
>  for 
> ftp.de.debian.org_debian_dists_testing_main_binary-amd64_Packages.diff_by-hash_SHA256_7caccf05e56ae4d753c02810d9f3ddff2e4b043e29dd6dae3f899e15ec66414d
> Checking for 
> ftp.de.debian.org_debian_dists_testing_main_binary-i386_Packages{,.gz,.xz,.bz2}
>  for 
> ftp.de.debian.org_debian_dists_testing_main_binary-i386_Packages.diff_by-hash_SHA256_5b692219d1090892f18a0b1d84e5504b72574b94c3167c2bb3625fdb8330b22f
> Checking for 
> ftp.de.debian.org_debian_dists_testing_main_i18n_Translation-en{,.gz,.xz,.bz2}
>  for 
> ftp.de.debian.org_debian_dists_testing_main_i18n_Translation-en.diff_by-hash_SHA256_210c49af092a400efe747dc414330297cd49304ce121a29fda35640d40fc4bab
> Checking for 
> ftp.de.debian.org_debian_dists_testing_main_source_Sources{,.gz,.xz,.bz2} for 
> ftp.de.debian.org_debian_dists_testing_main_source_Sources.diff_by-hash_SHA256_6bfd9b104752d28149c67e633ca654b7de9d6fd567ac025425d996b7b4ad66c4
> Get /ftp.de.debian.org/debian/dists/testing/main/i18n/Translation-en.xz
> Get /ftp.de.debian.org/debian/dists/testing/main/i18n/Translation-en.gz
> Get /ftp.de.debian.org/debian/dists/testing/main/i18n/Translation-en.bz2
> Get /ftp.de.debian.org/debian/dists/testing/main/source/Sources.xz
> Get /ftp.de.debian.org/debian/dists/testing/main/binary-amd64/Packages.xz
> Get /ftp.de.debian.org/debian/dists/testing/main/binary-i386/Packages.xz
> Get /ftp.de.debian.org/debian/dists/testing/InRelease

These are the cruicial lines: apt-get is updating its indices using
{Packages,Sources}.diff files so the complete index file doesn't get requested 
each
time and might not be in /var/cache/apt-cacher. The second patch ensures that
the full Packages and Sources files are present in /var/cache/apt-cacher for
each {Packages,Sources}.diff file so that apt-cacher can correctly keep valid
current packages.

> Reading: ftp.de.debian.org_debian_dists_testing_main_binary-amd64_Packages.xz
> Reading: ftp.de.debian.org_debian_dists_testing_main_binary-i386_Packages.xz
> Reading: ftp.de.debian.org_debian_dists_testing_main_source_Sources.xz

The complete index files are read

> Found 158132 valid file entries

and a realistic number of valid packages are found
 
> $ ls -la /var/cache/apt-cacher/packages/ftp.de.debian.org_debian
> drwxr-xr-x 2 www-data www-data    4096 Okt 14 23:34 .
> drwxr-xr-x 3 www-data www-data    4096 Okt 14 23:39 ..
> -rw-r--r-- 1 www-data www-data 1210410 Okt 14 23:34 aria2_1.32.0-1_amd64.deb

which means this valid package is not removed.

> Wow, seams that first cleaning the apt *cache.bin files to collect all need
> index/hash files from the repo anew, so that apt-cacher could cache it, and
> your patches did the job!
> 
> What/why did the behavior change that makes your patches necessary, although 
> some
> time ago all was working well? Questions over questions.

I suspect removing and recreating /var/cache/apt-cacher may have exposed it. But
I am happy to accept that is something apt-cacher should cope with and doesn't
differ from a new install.

> Now I tried it directly with the original version, just for the fun of it:
> 
> Invoked as root, changing to www-data:www-data and re-execing.

[snip]

> Reading: ftp.de.debian.org_debian_dists_testing_InRelease
> Reading: ftp.de.debian.org_debian_dists_testing_main_binary-amd64_Packages.xz
> Reading: ftp.de.debian.org_debian_dists_testing_main_binary-i386_Packages.xz
> Reading: ftp.de.debian.org_debian_dists_testing_main_source_Sources.xz

[snip]
 
> $ ls -la /var/cache/apt-cacher/packages/ftp.de.debian.org_debian
> drwxr-xr-x 2 www-data www-data    4096 Okt 14 23:34 .
> drwxr-xr-x 3 www-data www-data    4096 Okt 14 23:39 ..
> -rw-r--r-- 1 www-data www-data 1210410 Okt 14 23:34 aria2_1.32.0-1_amd64.deb
> 
> Now things are getting curious. Why does it now not delete the package
> anymore? Maybe somehow I have all/the right index files now.

Yes, the {Packages,Sources}.xz are still present.

> How can I ensure that in future

My second patch does that for you. You can verify , e.g., by something like a 
--force parameter for
> apt-get update? Why should I not have had the right index files for weeks
> before?

A combination of reasons: because you deleted /var/cache/apt-cacher and apt-get
is updating its indices with diff files and apt-cacher wasn't clever enough to
realise they were missing.

> Finally, just some of my thoughts on the game: How gets apt-get clean its
> similar job done for the package cache in /var/cache/apt/archives? The
> necessity of removing the *cache.bin files before apt-get update stems from
> the fact that for the index/hash data there is always a two level caching. 
> When there is a hit in the inner cache (apt), the outer one is not updated
> (apt-cacher).

The difference was that apt has to have complete index files and therefore made
sensible decisions. Until my second patch, apt-cacher just relied on what was in
the cache which was determined by what clients had requested through it.

I hope that clarifies.

Do do some more testing and live with it for a while.

If you don't mind I might pass you a cleaned up version of the patch to test?

Many thanks for your help.

Mark

Reply via email to