git-annex-shell: fix transfer hang

Fix hang when transferring the same objects to two different clients at the
same time. (Or when annex.pidlock is used, two different objects to the
same or different clients.)

Could also potentially occur if a client was downloading an object and
somehow lost connection but that git-annex-shell was still running and
holding the transfer lock.

This does not guarantee that, if `transfer` fails for some other reason,
a DATA response will be made.

This work is supported by the NIH-funded NICEMAN (ReproNim TR&D3) project.
This commit is contained in:
Joey Hess 2018-11-06 13:00:25 -04:00
parent bac7d34e71
commit 983c9d5a53
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 23 additions and 1 deletions

View file

@ -10,6 +10,7 @@
module Annex.Transfer ( module Annex.Transfer (
module X, module X,
upload, upload,
alwaysUpload,
download, download,
runTransfer, runTransfer,
alwaysRunTransfer, alwaysRunTransfer,
@ -39,6 +40,10 @@ upload :: Observable v => UUID -> Key -> AssociatedFile -> RetryDecider -> (Mete
upload u key f d a _witness = guardHaveUUID u $ upload u key f d a _witness = guardHaveUUID u $
runTransfer (Transfer Upload u key) f d a runTransfer (Transfer Upload u key) f d a
alwaysUpload :: Observable v => UUID -> Key -> AssociatedFile -> RetryDecider -> (MeterUpdate -> Annex v) -> NotifyWitness -> Annex v
alwaysUpload u key f d a _witness = guardHaveUUID u $
alwaysRunTransfer (Transfer Upload u key) f d a
download :: Observable v => UUID -> Key -> AssociatedFile -> RetryDecider -> (MeterUpdate -> Annex v) -> NotifyWitness -> Annex v download :: Observable v => UUID -> Key -> AssociatedFile -> RetryDecider -> (MeterUpdate -> Annex v) -> NotifyWitness -> Annex v
download u key f d a _witness = guardHaveUUID u $ download u key f d a _witness = guardHaveUUID u $
runTransfer (Transfer Download u key) f d a runTransfer (Transfer Download u key) f d a

View file

@ -1,3 +1,11 @@
git-annex (7.20181106) UNRELEASED; urgency=medium
* git-annex-shell: Fix hang when transferring the same objects to two
different clients at the same time. (Or when annex.pidlock is used,
two different objects.)
-- Joey Hess <id@joeyh.name> Tue, 06 Nov 2018 12:44:27 -0400
git-annex (7.20181105) upstream; urgency=medium git-annex (7.20181105) upstream; urgency=medium
* Fix test suite failure when git-annex test is not run inside a git * Fix test suite failure when git-annex test is not run inside a git

View file

@ -59,7 +59,8 @@ runLocal runst runner a = case a of
v <- tryNonAsync $ prepSendAnnex k v <- tryNonAsync $ prepSendAnnex k
case v of case v of
Right (Just (f, checkchanged)) -> proceed $ Right (Just (f, checkchanged)) -> proceed $
transfer upload k af $ -- Allow multiple uploads of the same key.
transfer alwaysUpload k af $
sinkfile f o checkchanged sender sinkfile f o checkchanged sender
Right Nothing -> proceed $ Right Nothing -> proceed $
runner (sender mempty (return Invalid)) runner (sender mempty (return Invalid))

View file

@ -0,0 +1,8 @@
[[!comment format=mdwn
username="joey"
subject="""comment 27"""
date="2018-11-06T16:55:17Z"
content="""
Preliminary fix in place, but have not yet done anything more to guarantee that
other failures don't prevent it from sending DATA.
"""]]