Commit graph

37189 commits

Author SHA1 Message Date
Joey Hess
24ff5e2b29
use uninterruptibleMask
Some recent changes to use mask missed that async exceptions can still
be thrown inside it. The goal is to make sure a block of cleanup code
runs entirely, w/o being interrupted by an async exception, so use
uninterruptibleMask.

Also, converted a few to bracket, which is nicer.
2020-06-09 15:02:56 -04:00
Joey Hess
7013798df5
async exception safety for coprocesses
Tested the forcerestart code path and it works.

The hairy part is, what if an async exception is caught when it's in
restart?

If it's in the part that stops the old process, the old process
is left in the handle. The next attempt to use the CoProcessHandle
will then throw an IO exception, which will result in restart getting
run again. So I think this will work, but have not actually tested it.

The use of withMVarMasked lets it start the new process and fill the
mvar with it, even if there's an async exception at that point.

Note that exceptions are masked while running forcerestart, so
do not need to worry about an async exception being thrown while it's
recovering from an async exception.
2020-06-09 13:44:23 -04:00
Joey Hess
a49d300545
async exception safety for external special remote processes
Since an external process can be in the middle of some operation when an
async exception is received, it has to be shut down then. Using
cleanupProcess will close its IO handles and send it a SIGTERM.

If a special remote choses to catch SIGTERM, it's fine for it to do some
cleanup then, but until it finishes, git-annex will be blocked waiting
for it. If a special remote blocked SIGTERM, it would cause a hang.
Mentioned in docs.

Also, in passing, fixed a FD leak, it was not closing the error handle
when shutting down the external. In practice that didn't matter before because
it was only run when git-annex was itself shutting down, but now that it
can run on exception, it would have been a problem.
2020-06-09 12:22:14 -04:00
Joey Hess
a294a27f9d
Merge branch 'master' of ssh://git-annex.branchable.com 2020-06-05 19:08:15 -04:00
Joey Hess
3ed797be0f
fix reversion
From back in 4be94c67c7.
Caused the test suite to fail, when bup is installed, but was not
noticed since the autobuilds don't have bup.
2020-06-05 19:06:09 -04:00
yarikoptic
8e3cdfa90e Added a comment 2020-06-05 22:15:09 +00:00
yarikoptic
04aa8360a9 Added a comment: reply to Joey's comments 2020-06-05 22:11:48 +00:00
Joey Hess
e41f8c83f3
close stdin handles before waiting on commands
Fixes reversion in recent conversions, the old code relied on the GC
apparently, but the new code explicitly waits on the process, so must
close stdin handle first or the command will never exit.
2020-06-05 17:27:49 -04:00
Joey Hess
ef0024444b
fix reversion
It was not the wrong handle. The handle was not being closed, so bup
kept running.

Before 2670890b17, the code was:

withHandle StdinHandle createProcessSuccess cmd feeder

The stdin handle was not closed by the feeder.

Testing this:

	withHandle StdinHandle createProcessSuccess (proc "cat" []) (\h -> hPutStrLn h "hi")

There's a rather long pause, a couple seconds, before it completes, but
it does complete. With hClose h, it immediately completes. This must be
the GC noticing that h is out of scope and closing it.

It seems likely that the old code worked only by that accident.

So, other similar changes made in that and nearby commits may also
have this problem, and need to explicitly close handles that were
somehow implicitly closed before.
2020-06-05 17:10:52 -04:00
Joey Hess
291774779f
use right handle 2020-06-05 16:45:12 -04:00
Joey Hess
05703893af
use right handle 2020-06-05 16:38:11 -04:00
Joey Hess
0fd72ff8e0
Merge branch 'master' of ssh://git-annex.branchable.com 2020-06-05 15:49:01 -04:00
Joey Hess
0210e81d83
async exception safety for openFd
Audited for openFile and openFd, and this fixes all the ones I found
where an async exception could prevent the file getting closed.

Except for the lock pool, which is a whole other can of worms.
2020-06-05 15:48:00 -04:00
Joey Hess
1dd770b1af
fix file descriptor leak
when importing from a directory special remote that is configured with
exporttree=yes
2020-06-05 15:34:43 -04:00
Joey Hess
319f2a4afc
audit all uses of SomeException to avoid catching async exceptions
Except for the assistant, which I think may use them between threads?

Most of the uses of SomeException were already catching only async exceptions.
But I did find a few places that were accidentially catching them.
2020-06-05 15:16:57 -04:00
mario
38d98ce550 Added a comment: Get missing files in --hide-missing branch 2020-06-05 19:14:26 +00:00
Joey Hess
dca19099a9
async exception safety
Masking ensures that EndStderrHandler gets written, so the helper
threads shut down.

However, nothing currently guarantees that calls to closeP2PSshConnection
are async exception safe, so made a note about it.

At this point, I've audited all calls to async, and made them all async
exception safe, except for ones in the assistant, and a few in leaf
commands (remotedaemon, enable-tor, multicast, p2p) which don't need to
be.
2020-06-05 14:56:41 -04:00
Joey Hess
a477f7253c
async exception safety 2020-06-05 14:42:11 -04:00
Joey Hess
660d8d3a87
simpler way to do this
Remove old code that can be trivially implemented using async in a much
nicer way (that is async exception safe).

I've audited all forkOS calls (except for ones in the assistant),
and this was the last remaining one that is not async exception safe.
The rest look ok to me.
2020-06-05 14:18:06 -04:00
Joey Hess
074260f036
async exception safety
Use async/cancel so helper threads are not left running.

Bracket createPipe to ensure the handles get closed.
2020-06-05 14:08:46 -04:00
Joey Hess
a0d09f1d9e
bracket createPipe for async exception safety 2020-06-05 13:58:04 -04:00
Joey Hess
9703ef8ae1
update 2020-06-05 12:12:20 -04:00
Joey Hess
b7619414bf
support building with process-1.6.3 again 2020-06-05 11:40:18 -04:00
Joey Hess
42756b972e
few more things 2020-06-05 11:15:29 -04:00
Joey Hess
db270bd6ba
Merge branch 'master' of ssh://git-annex.branchable.com 2020-06-05 11:13:15 -04:00
Joey Hess
2bff3b7c49
init: When annex.pidlock is set, skip lock probing. 2020-06-05 11:12:16 -04:00
Joey Hess
1d41ae5d2a
init warning on stalled lock probe
init: If lock probing stalls for a long time (eg a broken NFS server),
display a message to let the user know what's taking so long.
2020-06-05 11:06:19 -04:00
Ilya_Shlyakhter
1d189cd08e Added a comment 2020-06-05 14:51:08 +00:00
Joey Hess
e998e4a29a
Merge branch 'master' of ssh://git-annex.branchable.com 2020-06-05 10:41:30 -04:00
Joey Hess
b329cf32ec
fix reversion
Accidentially lost the handle setup in processTranscript.
2020-06-05 10:40:41 -04:00
Ilya_Shlyakhter
5bec5ff8d8 Added a comment: correct standalone tarball for git-annex-8.20200522 2020-06-05 06:21:07 +00:00
yarikoptic
08bc7a6867 reporting on SQLite3 problem rendering pidlocked system unusable 2020-06-05 02:31:21 +00:00
yarikoptic
8d3ffe50a1 initial whining about long pidlock need detection time 2020-06-05 02:18:31 +00:00
git-annex@17927e6dc041ab425c14217a97a685adf3ecf44f
31b8d6b440 Added a comment: Actually they were not standard 2020-06-04 21:05:48 +00:00
git-annex@17927e6dc041ab425c14217a97a685adf3ecf44f
0f4abb039c Added a comment: Actually they were not standard 2020-06-04 21:05:30 +00:00
git-annex@17927e6dc041ab425c14217a97a685adf3ecf44f
369382e8cf Added a comment: content expression is standard 2020-06-04 20:28:01 +00:00
Joey Hess
a3d1f967a8
almost forgot 2020-06-04 16:22:45 -04:00
Joey Hess
67f4ed1f55
Merge branch 'master' of ssh://git-annex.branchable.com 2020-06-04 15:53:10 -04:00
Joey Hess
3bd2bbb54c
devblog 2020-06-04 15:52:53 -04:00
Joey Hess
2670890b17
convert to withCreateProcess for async exception safety
This handles all createProcessSuccess callers, and aside from process
pools, the complete conversion of all process running to async exception
safety should be complete now.

Also, was able to remove from Utility.Process the old API that I now
know was not a good idea. And proof it was bad: The code size went *down*,
despite there being a fair bit of boilerplate for some future API to
reduce.
2020-06-04 15:45:52 -04:00
Joey Hess
12e7d52c8b
another wrinkle 2020-06-04 14:46:28 -04:00
Joey Hess
e4993b4456
async exception safety
Convert to withCreateProcess (missed this one a couple commits ago)
and also make sure that the child thread gets canceled on exception.
2020-06-04 12:57:22 -04:00
Joey Hess
bd3074643b
remove unused createBackgroundProcess 2020-06-04 12:48:42 -04:00
Joey Hess
20557cf0ef
stop exporting createProcessChecked
Yay, that had an ugly comment associated with it.
2020-06-04 12:46:55 -04:00
Joey Hess
438dbe3b66
convert to withCreateProcess for async exception safety
This handles all sites where checkSuccessProcess/ignoreFailureProcess
is used, except for one: Git.Command.pipeReadLazy
That one will be significantly more work to convert to bracketing.

(Also skipped Command.Assistant.autoStart, but it does not need to
shut down the processes it started on exception because they are
git-annex assistant daemons..)

forceSuccessProcess is done, except for createProcessSuccess.
All call sites of createProcessSuccess will need to be converted
to bracketing.

(process pools still todo also)
2020-06-04 12:44:09 -04:00
Joey Hess
2dc7b5186a
convert to withCreateProcess for async exception safety 2020-06-04 12:05:25 -04:00
nicolas
3319855083 2020-06-04 13:17:39 +00:00
Joey Hess
c429bbf2bd
remove workaround for old versions of process
ghc 8.4.4 has process 1.6.3, which was the first version to include
getPid.
2020-06-03 16:03:08 -04:00
Joey Hess
92f775eba0
convert to withCreateProcess for async exception safety
Not yet 100% done, so far I've grepped for waitForProcess and converted
everything that uses that to start the process with withCreateProcess.

Except for some things like P2P.IO and Assistant.TransferrerPool,
and Utility.CoProcess, that manage a pool of processes. See #2
in https://git-annex.branchable.com/todo/more_extensive_retries_to_mask_transient_failures/#comment-209f8a8c38e63fb3a704e1282cb269c7
for how those will need to be dealt with.

checkSuccessProcess, ignoreFailureProcess, and forceSuccessProcess calls waitForProcess, so
callers of them will also need to be dealt with, and have not been yet.
2020-06-03 15:48:09 -04:00
Joey Hess
1ee5919d1e
make createProcess calls async exception safe
Using cleanupProcess because withCreateProcess cannot run an Annex
action, but the effect is the same as using it.
2020-06-03 15:30:30 -04:00