-
Notifications
You must be signed in to change notification settings - Fork 710
Change moreRecentFile
test to workaround races
#2362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@23Skidoo alternatively, I could introduce a variant of By now I've found quite a few other cases that suffer from #2311 where I'm torn whether to edit the PS: The reason I changed -- | Compare the modification times of two files to see if the first is newer
-- than the second. The first file must exist but the second need not.
-- The expected use case is when the second file is generated using the first.
-- In this use case, if the result is True then the second file is out of date.
--
moreRecentFile :: FilePath -> FilePath -> IO Bool
moreRecentFile a b = do
exists <- doesFileExist b
if not exists
then return True
else do tb <- getModificationTime b
ta <- getModificationTime a
return (ta >= tb) |
Looking at the code, |
Please rename the function and document its behavior though. On Wed, Jan 14, 2015 at 5:00 PM, Mikhail Glushenkov <
|
This still won't completely solve #2311, though. When the tarball is extracted, there're 3 possible cases:
Case 1 works fine already; your patch fixes case 2, but case 3 (which I think can also happen) can't be fixed with this approach. |
This adds `notLessRecentFile a b` to return true not only when `a` is younger than `b`, but also when `a` is exactly the same age of `b`, as that case is subject to race-conditions (if the system time granularity is too low), and it's better to err on assuming it needs to be regenerated. This is an attempt to provide a pragmatic workaround for haskell#2311
6016771
to
b5fb044
Compare
@23Skidoo yeah... that's unfortunately true ... any suggestions? ( |
That doesn't help us with all the already existing releases having outdated pre-processed files in them, does it? Do we need to blacklist all of them for GHC >= 7.8? |
We can force-regenerate |
Given that the version of the preprocessor matters for making a package build, maybe this is an indication that it doesn't make sense to upload packages to Hackage with preprocessor output? I mean, I can understand why this original decision was made, but it just doesn't seem good if it causes this sort of problem. (Also, since new-build can automatically install Haskell preprocessors for you, this seems like even less of a good reason.) |
This changes
moreRecentFile a b
to return true not only whena
is younger than
b
, but also whena
is exactly the same age ofb
, asthat case is subject to race-conditions, and it's better to err on assuming
it needs to be regenerated.
This is an attempt to provide a pragmatic workaround for #2311