Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 352254 - >=app-arch/tar-1.25 doesn't preserve timestamps correctly (WAS: recent portage version process all updates after emerge-webrsync)
Summary: >=app-arch/tar-1.25 doesn't preserve timestamps correctly (WAS: recent portag...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-20 17:26 UTC by Jeremy Olexa (darkside) (RETIRED)
Modified: 2017-11-14 12:52 UTC (History)
1 user (show)

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


Attachments
set utime after closing file. (tar-1.25-utime.patch,859 bytes, patch)
2011-01-31 08:27 UTC, Markus Duft (RETIRED)
Details | Diff
fsync() before close() to sync timestamps to disk. (tar-1.25-utime.patch,496 bytes, patch)
2011-02-03 07:42 UTC, Markus Duft (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2011-01-20 17:26:33 UTC
I don't know when it started. But after every sync, I see every updates file being processed. Excuse the slim bug report...
Comment 1 Fabian Groffen gentoo-dev 2011-01-22 15:32:07 UTC
Seems to be after changes to the repository support for Portage.  I don't know what kind of heuristic it used to have before.
Comment 2 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2011-01-26 16:33:54 UTC
@dev-portage, does HEAD have this problem* too?

* The problem is, after a emerge-webrsync, I see messages for EVERY update file being processed.
Comment 3 Zac Medico gentoo-dev 2011-01-26 17:52:17 UTC
The code that triggers it it the portage.update.grab_updates() function. It compares mtimes from the mtimedb and triggers updates if the timestamps have changed since the last time portage ran.

Generally, you should only have updates triggered when the mtimes of files change inside $PORTDIR/profiles/updates. It can also be triggered by things such as changing the PORTDIR setting to a new path, since the mtime is recorded for the particular path. Also, changing from rsync tree to cvs tree or back again is a common way to trigger it since generally the two trees will have completely different profiles/updates mtimes.
Comment 4 Zac Medico gentoo-dev 2011-01-26 17:55:08 UTC
(In reply to comment #2)
> @dev-portage, does HEAD have this problem* too?

I never use emerge-webrsync, but it should preserve mtimes. Maybe tar is broken? The only recent related change in portage did not come until January 25 which was after you reported this bug:

http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d055cc9b6e46f37193841ef89843493e0d61ee7b

Comment 5 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2011-01-26 22:28:05 UTC
Thanks Zac. Removing you from CC.

Found the problem in tar-1.25 on the client side. It is doing something wrongly with timestamps because the server generating the tarballs is preserving the timestamps correctly. Once the files get to PORTAGE_TMPDIR, the timestamps are wrong and that is done with tar. After that ther eare rsync'd to PORTDIR.

@base-system: Tested tar-1.25{,-r1} to have this problem. tar-1.23-r4 does not. What can we do about it?
Comment 6 SpanKY gentoo-dev 2011-01-27 04:53:01 UTC
(1) come up with a simple testcase
(2) see if upstream tar git HEAD has same problem
(3) either report or find commit that fixes it
Comment 7 Markus Duft (RETIRED) gentoo-dev 2011-01-27 06:52:01 UTC
oh wow - i hit that yesterday, and thought it was interix specific ;) i don't have a solution yet though - still investigating here.
Comment 9 Markus Duft (RETIRED) gentoo-dev 2011-01-27 10:17:34 UTC
indeed, yes, that looks suspicious. i reverted the commit on my 1.25 tree and tried, but no luck... :(

also my suspicion that the utime() call would be effectless because close() right after it would re-write modification times is not true, so i'm back to cloning the git repo and reverting commits up until i have a working version...
Comment 10 Markus Duft (RETIRED) gentoo-dev 2011-01-28 14:59:51 UTC
is there a reproducible test case for linux? it is a pain to test this with interix (long turn around times), and it seems both vanilla and gentoo-patched 1.25 work on my gentoo box :(
Comment 11 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2011-01-28 16:01:45 UTC
(In reply to comment #10)
> is there a reproducible test case for linux? it is a pain to test this with
> interix (long turn around times), and it seems both vanilla and gentoo-patched
> 1.25 work on my gentoo box :(
> 

Markus, no. I'm not able to devise a 'simple' testcase for this issue. Although emerge-webrsync can reproduce it readily (everytime) here. I imagine a git bisect would reveal the problem commit, if I can ever find time for that =/
Comment 12 Markus Duft (RETIRED) gentoo-dev 2011-01-31 07:35:05 UTC
hmm... i did some more debugging on friday. it seems the problem is within gnulib, not tar. Also, setting a breakpoint in any of the gnulib utime related functions makes the problem disappear... a heisenbug - great.
Comment 13 Markus Duft (RETIRED) gentoo-dev 2011-01-31 07:55:19 UTC
hmm... interesting: if i set a breakpoint right _after_ setting utime of the file, it's correct. if i then kill tar, the stamp is wrong..?! darn... haubi said he had problems with close() resetting timestamps, but i was unable to pin the problem on that before...
Comment 14 Markus Duft (RETIRED) gentoo-dev 2011-01-31 08:27:21 UTC
Created attachment 261159 [details, diff]
set utime after closing file.

huh?! i re-tried moving the set_stat call after the close for each file, and suddenly it works...

hmm.. could you try tar with the attached patch whether it does the trick for you too? thanks
Comment 15 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2011-02-01 19:18:15 UTC
(In reply to comment #14)
> Created an attachment (id=261159) [details]
> set utime after closing file.
> 
> huh?! i re-tried moving the set_stat call after the close for each file, and
> suddenly it works...
> 
> hmm.. could you try tar with the attached patch whether it does the trick for
> you too? thanks
> 

confirmed, patch works for me.
Comment 16 Markus Duft (RETIRED) gentoo-dev 2011-02-02 07:24:01 UTC
[1] suggests, that both the patch and our filesystems are broken :) which fs have you tested on?

[1] http://www.mail-archive.com/bug-tar@gnu.org/msg03143.html
Comment 17 Markus Duft (RETIRED) gentoo-dev 2011-02-03 07:42:53 UTC
Created attachment 261397 [details, diff]
fsync() before close() to sync timestamps to disk.

upstream still thinks our filesystems are broken, as close() seems to get the wrong timestamp. the suggested solution (fsync() before close()) does work for me. can you test the new patch on linux too please? and tell me which filesystem your using please.
Comment 18 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2011-03-16 19:55:55 UTC
(In reply to comment #17)
> Created attachment 261397 [details, diff]
> fsync() before close() to sync timestamps to disk.
> 
> upstream still thinks our filesystems are broken, as close() seems to get the
> wrong timestamp. the suggested solution (fsync() before close()) does work for
> me. can you test the new patch on linux too please? and tell me which
> filesystem your using please.

Patch doesn't work for tar-1.26, only tar-1.25-r{0,1}. I can't answer what underlying fs I am on. NFS on NetApp Filer behind closed gates.
Comment 19 Markus Duft (RETIRED) gentoo-dev 2011-05-13 07:02:14 UTC
@jeremy: could you try defining HAVE_BUGGY_NFS_TIME_STAMPS during the tar build? that should fix your NFS problems.

regarding interix: the problem is to be solved in libsuacomp; i'm currently working on implementing the sync() and futimes() system calls. see [1]

[1] http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00305.html
Comment 20 Fabian Groffen gentoo-dev 2017-11-14 12:52:05 UTC
Closing this bug, Interix is gone, and later tar are reported to be ok.