init: Fix a reversion that broke initialization on systems that need to use pid locking
This brings back .git/annex/misctmp, but only for init. If an init is interrupted while probing using that temp directory, the files it left will get deleted 1 week later by a subsequent git-annex run.
This commit is contained in:
parent
07de0e7e9d
commit
94c75d2bd9
7 changed files with 42 additions and 13 deletions
|
@ -166,7 +166,7 @@ isInitialized = maybe Annex.Branch.hasSibling (const $ return True) =<< getVersi
|
||||||
{- A crippled filesystem is one that does not allow making symlinks,
|
{- A crippled filesystem is one that does not allow making symlinks,
|
||||||
- or removing write access from files. -}
|
- or removing write access from files. -}
|
||||||
probeCrippledFileSystem :: Annex Bool
|
probeCrippledFileSystem :: Annex Bool
|
||||||
probeCrippledFileSystem = withOtherTmp $ \tmp -> do
|
probeCrippledFileSystem = withEventuallyCleanedOtherTmp $ \tmp -> do
|
||||||
(r, warnings) <- liftIO $ probeCrippledFileSystem' tmp
|
(r, warnings) <- liftIO $ probeCrippledFileSystem' tmp
|
||||||
mapM_ warning warnings
|
mapM_ warning warnings
|
||||||
return r
|
return r
|
||||||
|
@ -229,7 +229,7 @@ probeLockSupport = do
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
return True
|
return True
|
||||||
#else
|
#else
|
||||||
withOtherTmp $ \tmp -> do
|
withEventuallyCleanedOtherTmp $ \tmp -> do
|
||||||
let f = tmp </> "lockprobe"
|
let f = tmp </> "lockprobe"
|
||||||
mode <- annexFileMode
|
mode <- annexFileMode
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
|
@ -247,7 +247,7 @@ probeFifoSupport = do
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
return False
|
return False
|
||||||
#else
|
#else
|
||||||
withOtherTmp $ \tmp -> do
|
withEventuallyCleanedOtherTmp $ \tmp -> do
|
||||||
let f = tmp </> "gaprobe"
|
let f = tmp </> "gaprobe"
|
||||||
let f2 = tmp </> "gaprobe2"
|
let f2 = tmp </> "gaprobe2"
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
|
|
|
@ -266,7 +266,8 @@ gitAnnexTmpOtherDir r = addTrailingPathSeparator $ gitAnnexDir r </> "othertmp"
|
||||||
gitAnnexTmpOtherLock :: Git.Repo -> FilePath
|
gitAnnexTmpOtherLock :: Git.Repo -> FilePath
|
||||||
gitAnnexTmpOtherLock r = gitAnnexDir r </> "othertmp.lck"
|
gitAnnexTmpOtherLock r = gitAnnexDir r </> "othertmp.lck"
|
||||||
|
|
||||||
{- Tmp directory used by old versions of git-annex. -}
|
{- .git/annex/misctmp/ was used by old versions of git-annex and is still
|
||||||
|
- used during initialization -}
|
||||||
gitAnnexTmpOtherDirOld :: Git.Repo -> FilePath
|
gitAnnexTmpOtherDirOld :: Git.Repo -> FilePath
|
||||||
gitAnnexTmpOtherDirOld r = addTrailingPathSeparator $ gitAnnexDir r </> "misctmp"
|
gitAnnexTmpOtherDirOld r = addTrailingPathSeparator $ gitAnnexDir r </> "misctmp"
|
||||||
|
|
||||||
|
|
26
Annex/Tmp.hs
26
Annex/Tmp.hs
|
@ -7,9 +7,8 @@
|
||||||
|
|
||||||
module Annex.Tmp where
|
module Annex.Tmp where
|
||||||
|
|
||||||
import Common
|
import Annex.Common
|
||||||
import Annex
|
import qualified Annex
|
||||||
import Annex.Locations
|
|
||||||
import Annex.LockFile
|
import Annex.LockFile
|
||||||
import Annex.Perms
|
import Annex.Perms
|
||||||
import Types.CleanupActions
|
import Types.CleanupActions
|
||||||
|
@ -24,13 +23,30 @@ import Data.Time.Clock.POSIX
|
||||||
-- any time.
|
-- any time.
|
||||||
withOtherTmp :: (FilePath -> Annex a) -> Annex a
|
withOtherTmp :: (FilePath -> Annex a) -> Annex a
|
||||||
withOtherTmp a = do
|
withOtherTmp a = do
|
||||||
addCleanup OtherTmpCleanup cleanupOtherTmp
|
Annex.addCleanup OtherTmpCleanup cleanupOtherTmp
|
||||||
tmpdir <- fromRepo gitAnnexTmpOtherDir
|
tmpdir <- fromRepo gitAnnexTmpOtherDir
|
||||||
tmplck <- fromRepo gitAnnexTmpOtherLock
|
tmplck <- fromRepo gitAnnexTmpOtherLock
|
||||||
withSharedLock (const tmplck) $ do
|
withSharedLock (const tmplck) $ do
|
||||||
void $ createAnnexDirectory tmpdir
|
void $ createAnnexDirectory tmpdir
|
||||||
a tmpdir
|
a tmpdir
|
||||||
|
|
||||||
|
-- | This uses an alternate temp directory. The action should normally
|
||||||
|
-- clean up whatever files it writes there, but if it leaves files
|
||||||
|
-- there (perhaps due to being interrupted), the files will be eventually
|
||||||
|
-- cleaned up by another git-annex process (after they're a week old).
|
||||||
|
--
|
||||||
|
-- Unlike withOtherTmp, this does not rely on locking working.
|
||||||
|
-- Its main use is in situations where the state of lockfile is not
|
||||||
|
-- determined yet, eg during initialization.
|
||||||
|
withEventuallyCleanedOtherTmp :: (FilePath -> Annex a) -> Annex a
|
||||||
|
withEventuallyCleanedOtherTmp = bracket setup cleanup
|
||||||
|
where
|
||||||
|
setup = do
|
||||||
|
tmpdir <- fromRepo gitAnnexTmpOtherDirOld
|
||||||
|
void $ createAnnexDirectory tmpdir
|
||||||
|
return tmpdir
|
||||||
|
cleanup = liftIO . void . tryIO . removeDirectory
|
||||||
|
|
||||||
-- | Cleans up any tmp files that were left by a previous
|
-- | Cleans up any tmp files that were left by a previous
|
||||||
-- git-annex process that got interrupted or failed to clean up after
|
-- git-annex process that got interrupted or failed to clean up after
|
||||||
-- itself for some other reason.
|
-- itself for some other reason.
|
||||||
|
@ -42,8 +58,6 @@ cleanupOtherTmp = do
|
||||||
void $ tryIO $ tryExclusiveLock (const tmplck) $ do
|
void $ tryIO $ tryExclusiveLock (const tmplck) $ do
|
||||||
tmpdir <- fromRepo gitAnnexTmpOtherDir
|
tmpdir <- fromRepo gitAnnexTmpOtherDir
|
||||||
void $ liftIO $ tryIO $ removeDirectoryRecursive tmpdir
|
void $ liftIO $ tryIO $ removeDirectoryRecursive tmpdir
|
||||||
-- This is only to clean up cruft left by old versions of
|
|
||||||
-- git-annex; it can be removed eventually.
|
|
||||||
oldtmp <- fromRepo gitAnnexTmpOtherDirOld
|
oldtmp <- fromRepo gitAnnexTmpOtherDirOld
|
||||||
liftIO $ mapM_ cleanold =<< dirContentsRecursive oldtmp
|
liftIO $ mapM_ cleanold =<< dirContentsRecursive oldtmp
|
||||||
liftIO $ void $ tryIO $ removeDirectory oldtmp -- when empty
|
liftIO $ void $ tryIO $ removeDirectory oldtmp -- when empty
|
||||||
|
|
|
@ -25,6 +25,8 @@ git-annex (7.20190826) UNRELEASED; urgency=medium
|
||||||
in working tree.
|
in working tree.
|
||||||
* Avoid making a commit when upgrading from direct mode to v7.
|
* Avoid making a commit when upgrading from direct mode to v7.
|
||||||
* init: Catch more exceptions when testing locking.
|
* init: Catch more exceptions when testing locking.
|
||||||
|
* init: Fix a reversion that broke initialization on systems that
|
||||||
|
need to use pid locking.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Sat, 24 Aug 2019 12:54:35 -0400
|
-- Joey Hess <id@joeyh.name> Sat, 24 Aug 2019 12:54:35 -0400
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,5 @@ running createProcess with this:
|
||||||
|
|
||||||
CreateProcess {cmdspec = RawCommand "git" ["update-index","--index-info"], cwd = Nothing, env = Just [("GIT_INDEX_FILE","/tmp/\56514\56481/.git/annex/index")], std_in = Inherit, std_out = Inherit, std_err = Inherit, close_fds = False, create_group = False, delegate_ctlc = False, detach_console = False, create_new_console = False, new_session = False, child_group = Nothing, child_user = Nothing, use_process_jobs = False}
|
CreateProcess {cmdspec = RawCommand "git" ["update-index","--index-info"], cwd = Nothing, env = Just [("GIT_INDEX_FILE","/tmp/\56514\56481/.git/annex/index")], std_in = Inherit, std_out = Inherit, std_err = Inherit, close_fds = False, create_group = False, delegate_ctlc = False, detach_console = False, create_new_console = False, new_session = False, child_group = Nothing, child_user = Nothing, use_process_jobs = False}
|
||||||
|
|
||||||
This bug needs to be forwarded to http://hackage.haskell.org/process,
|
This bug needs to be forwarded to process.
|
||||||
after checking what environment value it actually passes to the child
|
|
||||||
process in this case.
|
|
||||||
"""]]
|
"""]]
|
||||||
|
|
|
@ -62,3 +62,5 @@ type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp
|
||||||
```
|
```
|
||||||
|
|
||||||
[[!meta author=yoh]]
|
[[!meta author=yoh]]
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 4"""
|
||||||
|
date="2019-09-10T16:28:12Z"
|
||||||
|
content="""
|
||||||
|
Thanks for the bisection. It's not the init code that's
|
||||||
|
trying and failing to set a lock, but the misctmp cleanup code. Which is
|
||||||
|
ironically now used in setting up the temp directory that init uses to
|
||||||
|
probe for locking problems. Chicken and egg problem.
|
||||||
|
|
||||||
|
Committed a fix.
|
||||||
|
"""]]
|
Loading…
Reference in a new issue