Debian Bug report logs - #715494
apt-pkg: out-of-date pkgcache.bin: /var/lib/dpkg/status updated more than once in one second

version graph

Package: apt; Maintainer for apt is APT Development Team <[email protected]>; Source for apt is src:apt (PTS, buildd, popcon).

Reported by: Philipp Hahn <[email protected]>

Date: Tue, 9 Jul 2013 17:15:02 UTC

Severity: normal

Found in version apt/0.8.10

Reply or subscribe to this bug.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to [email protected], APT Development Team <[email protected]>:
Bug#715494; Package apt. (Tue, 09 Jul 2013 17:15:06 GMT) (full text, mbox, link).


Acknowledgement sent to Philipp Hahn <[email protected]>:
New Bug report received and forwarded. Copy sent to APT Development Team <[email protected]>. (Tue, 09 Jul 2013 17:15:06 GMT) (full text, mbox, link).


Message #5 received at [email protected] (full text, mbox, reply):

From: Philipp Hahn <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Subject: apt-pkg: out-of-date pkgcache.bin: /var/lib/dpkg/status updated more than once in one second
Date: Tue, 09 Jul 2013 19:05:23 +0200
Package: apt
Version: 0.8.10
Severity: normal

Dear Maintainer,

we (Univention GmbH) provide a Debian based distribution called "UCS".
During automatic testing we noticed a suitable bug in APT:

If /var/lib/dpkg/status is updated more than once in one second, apt-pkg
does not detect that and does not update its /var/cache/apt/pkgcache.bin
file.
"dpkg-query -W" and "apt-cache policy" then display different versions
for the currently installed version.

I tracked it down to apt-pkg/pkgcache.cc and apt-pkg/deb/debindexfile.cc
only using 'stat.mtime' without the nano-second resolution in 'tv_nsec',
which more modern Linux kernels do provide.

Would you accept a patch which adds (conditional) support for that, or
do you prefer a different solution.


The bug is more likely to happen on fast machines and in virtual
machines, where the expensive disk sync get filtered out.

The full bug information is available in our public Bugzilla at
<https://forge.univention.org/bugzilla/show_bug.cgi?id=31773>

Sincerely
Philipp Hahn <[email protected]>
-- Package-specific info:

-- System Information:
Debian Release: 7.1
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages apt depends on:
ii  debian-archive-keyring  2012.4
ii  gnupg                   1.4.12-7
ii  libapt-pkg4.12          0.9.7.9
ii  libc6                   2.13-38
ii  libgcc1                 1:4.7.2-5
ii  libstdc++6              4.7.2-5

apt recommends no packages.

Versions of packages apt suggests:
pn  apt-doc     <none>
ii  aptitude    0.6.8.2-1
ii  dpkg-dev    1.16.10
ii  python-apt  0.8.8.2
ii  xz-utils    5.1.1alpha+20120614-2

-- no debconf information



Information forwarded to [email protected], APT Development Team <[email protected]>:
Bug#715494; Package apt. (Tue, 09 Jul 2013 19:03:07 GMT) (full text, mbox, link).


Acknowledgement sent to David Kalnischkies <[email protected]>:
Extra info received and forwarded to list. Copy sent to APT Development Team <[email protected]>. (Tue, 09 Jul 2013 19:03:07 GMT) (full text, mbox, link).


Message #10 received at [email protected] (full text, mbox, reply):

From: David Kalnischkies <[email protected]>
To: Philipp Hahn <[email protected]>, [email protected]
Subject: Re: Bug#715494: apt-pkg: out-of-date pkgcache.bin: /var/lib/dpkg/status updated more than once in one second
Date: Tue, 9 Jul 2013 21:00:41 +0200
On Tue, Jul 9, 2013 at 7:05 PM, Philipp Hahn <[email protected]> wrote:
> If /var/lib/dpkg/status is updated more than once in one second, apt-pkg
> does not detect that and does not update its /var/cache/apt/pkgcache.bin
> file.
> "dpkg-query -W" and "apt-cache policy" then display different versions
> for the currently installed version.

That's bad indeed. All sorts of strange stuff can happen then APT and
dpkg have a different view on the world.

> I tracked it down to apt-pkg/pkgcache.cc and apt-pkg/deb/debindexfile.cc
> only using 'stat.mtime' without the nano-second resolution in 'tv_nsec',
> which more modern Linux kernels do provide.

Documentation says tv_nsec is specified in POSIX.1-2008, so that will
be fine and should be kernel-independent. APT uses other POSIX.1-2008
stuff already, so this isn't raising any invisible requirement bars either.
Supporting filesystems seems to be the bigger limitation but we can't fix that.

> Would you accept a patch which adds (conditional) support for that, or
> do you prefer a different solution.

The alternative would be going with checksums and at that point it would
be probably faster to just parse it all the time rather than doing checksums,
so yes, if you have a patch please feel free to share it with us. :)

Without checking I presume this is a binary incompatible change though
as it changes internal structures, so this has to wait for an abi-break
(we usually collect a bunch of stuff as they tend to be painful) and can't
be backported to stable.


> The bug is more likely to happen on fast machines and in virtual
> machines, where the expensive disk sync get filtered out.

You seem to be extra-ordinary "lucky", as the file needs to retain
the same size as well.


> The full bug information is available in our public Bugzilla at
> <https://forge.univention.org/bugzilla/show_bug.cgi?id=31773>

I would suggest disabling at least one of the binary caches as a
workaround instead:
echo 'Dir::Cache::pkgcache "";' > /etc/apt/apt.conf.d/nocache
Its the cache combining the data parsed from the sources
(called srcpkgcache – so it has nothing to do with source packages!)
with the data parsed from the status file. Caches which aren't
created can't be out-of-date. ;)


Best regards

David Kalnischkies



Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Sun Sep 22 07:24:43 2024; Machine Name: bembo

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.