diff options
author | Joey Hess <joey@kitenet.net> | 2011-06-23 15:51:07 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-06-23 16:05:02 -0400 |
commit | 7981eb4cb512fbe3c49a3dd165c31be14ae4bc49 (patch) | |
tree | 157497de52adaf40f7589f06e01c46607f36d158 /Branch.hs | |
parent | 780ee5ff6d3fdcbbe69450d40260c1083315ca47 (diff) |
fix consistency, and partially close a race during merge
Only "partially" because the journal is not locked during the merge, so
there's a small window where a different git-annex process could write info
to the journal that overwrites info taken from the merge.
That could be dealt with by locking, but the lock would really need to be
around the whole git-annex, to only let one run at a time. Otherwise, even
with the journal locked during the merge, another git-annex could already
be running, generate an overwriting change, and only store it in the journal
after the merge was complete. And similarly, two git-annex processes could
fight and overwrite each other's information independant of any merging.
So, a toplevel lock for git-annex may get added; it's something I've
considered before, as these potential, unlikely problems are not new.
(OTOH, fsck will deal with such problems.)
Diffstat (limited to 'Branch.hs')
-rw-r--r-- | Branch.hs | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -149,6 +149,21 @@ update :: Annex () update = do state <- Annex.getState Annex.branchstate unless (branchUpdated state) $ withIndex $ do + {- Since branches get merged into the index, it's important to + - first stage the journal into the index. Otherwise, any + - changes in the journal would later get staged, and might + - overwrite changes made during the merge. + - + - It would be cleaner to handle the merge by updating the + - journal, not the index, with changes from the branches. + - + - XXX Anything written to the journal during the merge, + - by another process could still race the merge. The + - journal should really be blocking locked during the + - merge. + -} + _ <- stageJournalFiles + g <- Annex.gitRepo r <- liftIO $ Git.pipeRead g [Param "show-ref", Param name] let refs = map (last . words) (lines r) |