fix cat-file leak in get with -J
authorJoey Hess <joeyh@joeyh.name>
Fri, 19 Nov 2021 16:51:08 +0000 (12:51 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 19 Nov 2021 16:51:08 +0000 (12:51 -0400)
commit623a775609c486b5cd3441c5bca7c3d4a988eae0
tree2a2d24b3f487e09410bfa6fd2fe73c1eda0767aa
parent2d3e8718e64d5fc0a30738d2d4a25a52d84ec7a4
fix cat-file leak in get with -J

Bugfix: When -J was enabled, getting files leaked a ever-growing number of
git cat-file processes.

(Since commit dd39e9e255a5684824ea75861f48f658eaaba288)

The leak happened when mergeState called stopNonConcurrentSafeCoProcesses.
While stopNonConcurrentSafeCoProcesses usually manages to stop everything,
there was a race condition where cat-file processes were leaked. Because
catFileStop modifies Annex.catfilehandles in a non-concurrency safe way,
and could clobber modifications made in between. Which should have been ok,
since originally catFileStop was only used at shutdown.

Note the comment on catFileStop saying it should only be used when nothing
else is using the handles. It would be possible to make catFileStop
race-safe, but it should just not be used in a situation where a race is
possible. So I didn't bother.

Instead, the fix is just not to stop any processes in mergeState. Because
in order for mergeState to be called, dupState must have been run, and it
enables concurrency mode, stops any non-concurrent processes, and so all
processes that are running are concurrency safea. So there is no need to
stop them when merging state. Indeed, stopping them would be extra work,
even if there was not this bug.

Sponsored-by: Dartmouth College's Datalad project
Annex/Action.hs
Annex/Concurrent.hs
CHANGELOG
doc/forum/git-annex_causing_zombie_git_processes_to_build_up.mdwn
doc/forum/git-annex_causing_zombie_git_processes_to_build_up/comment_13_41e0fada90d795b9be12929ed66231e1._comment [new file with mode: 0644]