Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 306659 - portage-2.2_rc63 does senseless reinstalls
Summary: portage-2.2_rc63 does senseless reinstalls
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Dependencies (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS, REGRESSION
Depends on:
Blocks:
 
Reported: 2010-02-24 15:28 UTC by Victor Mataré
Modified: 2010-03-03 11:13 UTC (History)
0 users

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


Attachments
trigger --rebuilt-binarie with --usepkgonly instead of --usepkg (usepkgonly.patch,537 bytes, patch)
2010-02-24 20:51 UTC, Zac Medico
Details | Diff
bogus emergelist (emergelist,3.38 KB, text/plain)
2010-02-24 23:03 UTC, Victor Mataré
Details
only reinstall if binary package has non-empty BUILD_TIME field (rebuilt_binaries.patch,801 bytes, patch)
2010-03-02 05:48 UTC, Zac Medico
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Mataré 2010-02-24 15:28:11 UTC
After upgrading from rc62 to rc63, portage keeps reinstalling all packages that were updated along with the portage update on every subsequent world update. Results in a bunch of meaningless reinstalls on every world update. This bug seems to trigger only if the system is using binary packages. On the source system providing the binpkgs, everything seems fine. Downgrading to rc62 makes the reinstalls go away. Upgrade back to rc63 and they're there again.

Reproducible: Always

Steps to Reproduce:
Comment 1 Victor Mataré 2010-02-24 16:30:07 UTC
addendum: It must be something in the criteria for determining if a tbz2 needs to be reinstalled. When I run portage without -g (and without FEATURES=getbinpkg), it works correctly. Whenever I do emerge -guDavN world, it will reinstall those packages over and over. However I've got no idea what determines the set of packages that are affected by this. They're definitely the ones that were updated when portage was first updated from 2.2_rc62 to 2.2_rc63. So they probably were in the resume list at the time, but dunno how that might be persisted in this strange kind of way...
Comment 2 Zac Medico gentoo-dev 2010-02-24 20:51:46 UTC
Created attachment 221037 [details, diff]
trigger --rebuilt-binarie with --usepkgonly instead of --usepkg

It may be related to the new --rebuilt-binaries option which is triggered automatically with --usepkg/--getbinpkg --update --deep. You can use --rebuilt-binaries=n to forcefully disable it. In svn (patch attached) I've changed the behavior so that it's only triggered automatically with --usepkgonly or --getbinpkgonly.
Comment 3 Victor Mataré 2010-02-24 21:43:14 UTC
Yup, running the world update with --rebuilt-binaries=n makes the useless reinstalls go away. So I guess there's some breakage in the comparison of the metadata that makes it trigger every time. Not sure why it keeps futzing around on the pkgs from the resume list, though. I have now upgraded and downgraded portage several times from and to rc62 and rc63, but it still wants to reinstall the binpkgs from the resume list when I first updated to rc63. Where does it save that resume list, btw?
Comment 4 Zac Medico gentoo-dev 2010-02-24 21:46:08 UTC
The resume list is saved in /var/cache/edb/mtimedb. You can purge it with `emaint --fix cleanresume`.
Comment 5 Victor Mataré 2010-02-24 22:01:00 UTC
(In reply to comment #4)
> The resume list is saved in /var/cache/edb/mtimedb. You can purge it with
> `emaint --fix cleanresume`.
> 
Hum. Doing that doesn't help. However I noticed that the Packages index on the server side has those BUILD_TIME entries whereas /var/cache/edb/binhost/horst.phuk.ath.cx/packages/pentium-m/Packages differs from it exactly in *not* having them. Diff looks like this

344d343
< BUILD_TIME: 1266867281
412d410
< BUILD_TIME: 1266851415
527d524
< BUILD_TIME: 1266861057
812d808
< BUILD_TIME: 1266867559
876d871
< BUILD_TIME: 1266865732
891d885
< BUILD_TIME: 1266866806
1241d1234
< BUILD_TIME: 1266868373
1286d1278
< BUILD_TIME: 1266719707

Dunno if that means anything...
Comment 6 Zac Medico gentoo-dev 2010-02-24 22:25:31 UTC
(In reply to comment #5)
> Hum. Doing that doesn't help. However I noticed that the Packages index on the
> server side has those BUILD_TIME entries whereas
> /var/cache/edb/binhost/horst.phuk.ath.cx/packages/pentium-m/Packages differs
> from it exactly in *not* having them.

I think the local copy doesn't have them because it got downloaded by an older version of portage. If you removed the cached copy on the client then it should solve the problem. It's not being downloaded again because the timestamp in the header hasn't changed since the last time it was downloaded.
Comment 7 Victor Mataré 2010-02-24 22:37:21 UTC
> I think the local copy doesn't have them because it got downloaded by an older
> version of portage. If you removed the cached copy on the client then it should
> solve the problem. It's not being downloaded again because the timestamp in the
> header hasn't changed since the last time it was downloaded.
> 

Nope. Deleted it and now the Package indices are the same, but so is the set of tbz2's it wants to reinstall over and over.
Comment 8 Zac Medico gentoo-dev 2010-02-24 22:45:07 UTC
Can you check if there is any difference between /var/db/pkg/*/*/BUILD_TIME and the corresponding BUILD_TIME entries in the cached Packages file from the binhost? It should only reinstall if those are different for some reason.
Comment 9 Victor Mataré 2010-02-24 22:52:05 UTC
ok, picking media-gfx/ufraw-0.16:

# cat /var/db/pkg/media-gfx/ufraw-0.16/BUILD_TIME
1266705894

# grep -B 1 "CPV: media-gfx/ufraw-0.16" /var/cache/edb/binhost/horst.phuk.ath.cx/packages/pentium-m/Packages
BUILD_TIME: 1266705894
CPV: media-gfx/ufraw-0.16
Comment 10 Victor Mataré 2010-02-24 23:03:52 UTC
Created attachment 221045 [details]
bogus emergelist

btw, this is the output of "emerge -guDpvN world", whereas when using --rebuilt-binaries=n, no packages are merged. One more BUILD_TIME example from the list:

# cat /var/db/pkg/media-libs/jpeg-8/BUILD_TIME
1266701067

# grep -B 1 "CPV: media-libs/jpeg-8" /var/cache/edb/binhost/horst.phuk.ath.cx/packages/pentium-m/Packages
BUILD_TIME: 1266701067
CPV: media-libs/jpeg-8
Comment 11 Zac Medico gentoo-dev 2010-02-24 23:04:24 UTC
Maybe there's something wrong with the /var/db/pkg metadata cache. You can check the cached BUILD_TIME value like this:

  portageq metadata / installed media-gfx/ufraw-0.16 BUILD_TIME
Comment 12 Victor Mataré 2010-02-24 23:19:17 UTC
(In reply to comment #11)
> Maybe there's something wrong with the /var/db/pkg metadata cache. You can
> check the cached BUILD_TIME value like this:
> 
>   portageq metadata / installed media-gfx/ufraw-0.16 BUILD_TIME
> 
# portageq metadata / installed media-gfx/ufraw-0.16 BUILD_TIME
1266705894
# portageq metadata / installed media-libs/jpeg-8 BUILD_TIME
1266701067

good thing I learn a bit more about portage's binpkg handling this way^^
Comment 13 Zac Medico gentoo-dev 2010-02-24 23:42:31 UTC
Strangely, those BUILD_TIME look like they all match. What about in $PKGDIR/Packages? Does it contain correct BUILD_TIME values? You can also query them like this:

  portageq metadata / binary media-gfx/ufraw-0.16 BUILD_TIME
Comment 14 Victor Mataré 2010-02-24 23:52:39 UTC
(In reply to comment #13)
> Strangely, those BUILD_TIME look like they all match. What about in
> $PKGDIR/Packages? Does it contain correct BUILD_TIME values? You can also query
> them like this:
> 
>   portageq metadata / binary media-gfx/ufraw-0.16 BUILD_TIME
> 

Ah, now this looks like something, as in, nothing:
# portageq metadata / binary media-gfx/ufraw-0.16 BUILD_TIME

# portageq metadata / binary media-libs/jpeg-8 BUILD_TIME

(it outputs an empty line)...
So let's clean that package index:
# mv /usr/portage/packages/Packages ~
and retry:
# emerge -guDpvN world

These are the packages that would be merged, in order:

Calculating dependencies... done!

Total: 0 packages, Size of downloads: 0 kB

Fair enough. Now the question remains: Why are there two copies of that Package index and why weren't they updated?
Comment 15 Victor Mataré 2010-02-25 00:05:04 UTC
I think we should make absolutely sure we have the latest index file when using --rebuilt-binaries=y. That is, just download it.
Thinking of that, I remember that I did have some issues with Package indices not getting updated a few months ago. I also resolved them by removing the local copy, but I hadn't seen these problems in a while, so I didn't bother to report. But maybe the code for (not) downloading the index file should get some attention.
Comment 16 Zac Medico gentoo-dev 2010-02-25 00:11:20 UTC
(In reply to comment #14)
> Fair enough. Now the question remains: Why are there two copies of that Package
> index and why weren't they updated?

One copy is for $PKGDIR and the other is for the remote binhost.

They were both missing BUILD_TIME metadata because they were generated by older portage. I'm not sure how to fix it yet.
Comment 17 Victor Mataré 2010-02-25 00:35:40 UTC
> One copy is for $PKGDIR and the other is for the remote binhost.

Shouldn't those two ideally be always in sync? As far as I can see the client $PKGDIR copy also contains all binpkgs that exist on the server-side, and not just the ones that have in fact been downloaded.
As I understand it, the local state is in /var/db/pkg, and the remote state is in $PKGDIR/Packages. Or does the Packages index also reflect some kind of local state (given I don't build binpkgs on the client side)?
BTW, is there any more technical documentation available on this? I find the docs I've read so far to be somewhat... well... shallow, on the topic of binary package use.
Comment 18 Zac Medico gentoo-dev 2010-02-25 00:56:40 UTC
(In reply to comment #17)
> > One copy is for $PKGDIR and the other is for the remote binhost.
> 
> Shouldn't those two ideally be always in sync? As far as I can see the client
> $PKGDIR copy also contains all binpkgs that exist on the server-side, and not
> just the ones that have in fact been downloaded.
> As I understand it, the local state is in /var/db/pkg, and the remote state is
> in $PKGDIR/Packages. Or does the Packages index also reflect some kind of local
> state (given I don't build binpkgs on the client side)?

$PKGDIR/Packages is strictly for caching local package metadata. Remote packages get merged into it as soon as they are downloaded.

> BTW, is there any more technical documentation available on this? I find the
> docs I've read so far to be somewhat... well... shallow, on the topic of binary
> package use.

No, it's almost completely undocumented at this time.
Comment 19 Zac Medico gentoo-dev 2010-02-25 08:57:04 UTC
My plan is to write an upgrade script that will run in pkg_postinst when upgrading from a version of portage that doesn't support BUILD_TIME. The script will purge /var/cache/edb/binhost/ and add missing BUILD_TIME entries to $PKGDIR/Packages.
Comment 20 Zac Medico gentoo-dev 2010-03-02 05:48:11 UTC
Created attachment 221751 [details, diff]
only reinstall if binary package has non-empty BUILD_TIME field 

This is a really simple fix, and should handle all relevant cases.
Comment 21 Zac Medico gentoo-dev 2010-03-03 11:13:25 UTC
This is fixed in 2.2_rc64.