Commit graph

41034 commits

Author SHA1 Message Date
Joey Hess
ef3ab0769e
close pid lock only once no threads use it
This fixes a FD leak when annex.pidlock is set and -J is used. Also, it
fixes bugs where the pid lock file got deleted because one thread was
done with it, while another thread was still holding it open.

The LockPool now has two distinct types of resources,
one is per-LockHandle and is used for file Handles, which get closed
when the associated LockHandle is closed. The other one is per lock
file, and gets closed when no more LockHandles use that lock file,
including other shared locks of the same file.

That latter kind is used for the pid lock file, so it's opened by the
first thread to use a lock, and closed when the last thread closes a lock.

In practice, this means that eg git-annex get of several files opens and
closes the pidlock file a few times per file. While with -J5 it will open
the pidlock file, process a number of files, until all the threads happen to
finish together, at which point the pidlock file gets closed, and then
that repeats. So in either case, another process still gets a chance to
take the pidlock.

registerPostRelease has a rather intricate dance, there are fine-grained
STM locks, a STM lock of the pidfile itself, and the actual pidlock file
on disk that are all resolved in stages by it.

Sponsored-by: Dartmouth College's Datalad project
2021-12-06 15:01:39 -04:00
Joey Hess
774c7dab2f
Merge branch 'master' into pidlockfinegrained 2021-12-06 13:00:40 -04:00
Joey Hess
7c78fae463
Merge branch 'master' of ssh://git-annex.branchable.com 2021-12-06 12:53:43 -04:00
Joey Hess
ae4c56b28a
Revert "fix too early close of shared lock file"
This reverts commit 66b2536ea0.

I misunderstood commit ac56a5c2a0
and caused a FD leak when pid locking is not used.

A LockHandle contains an action that will close the underlying lock
file, and that action is run when it is closed. In the case of a shared
lock, the lock file is opened once for each LockHandle, and only
the one for the LockHandle that is being closed will be closed.
2021-12-06 12:51:28 -04:00
alt
371238eca3 2021-12-06 15:56:56 +00:00
jasonb@ab4484d9961a46440958fa1a528e0fc435599057
a8ff96864e 2021-12-05 20:37:48 +00:00
Joey Hess
00625caf87
update 2021-12-05 08:11:41 -04:00
Joey Hess
490689f122
Merge branch 'master' of ssh://git-annex.branchable.com 2021-12-03 18:42:05 -04:00
Joey Hess
e464ffd641
update comment to current status 2021-12-03 18:41:51 -04:00
Joey Hess
9d3dce94f0
comment 2021-12-03 18:41:34 -04:00
yarikoptic
8a3b6f46c8 Added a comment 2021-12-03 21:41:53 +00:00
Joey Hess
e5ca67ea1c
fine-grained locking when annex.pidlock is enabled
This locking has been missing from the beginning of annex.pidlock.
It used to be possble, when two threads are doing conflicting things,
for both to run at the same time despite using locking. Seems likely
that nothing actually had a problem, but it was possible, and this
eliminates that possible source of failure.

Sponsored-by: Dartmouth College's Datalad project
2021-12-03 17:20:21 -04:00
Joey Hess
a5fcc03595
comment 2021-12-03 16:40:58 -04:00
Joey Hess
6988c2e740
fix build on windows
broken by ed0afbc36b

Sponsored-by: Dartmouth College's Datalad project
2021-12-03 14:08:12 -04:00
ashton@37fa3fec6d2eef022a3491c85362a34141fbf0db
5d9cc3e5af 2021-12-02 23:36:10 +00:00
yarikoptic
3205686faf Added a comment 2021-12-02 20:42:37 +00:00
yarikoptic
d88a52886d removed 2021-12-02 20:41:37 +00:00
yarikoptic
33c36ef5cb initial follow up on the read-only mode issue 2021-12-02 20:39:39 +00:00
yarikoptic
937b9de516 Added a comment: automate + extend 2021-12-02 20:34:55 +00:00
yarikoptic
9c0f3d1de8 Added a comment 2021-12-02 13:05:55 +00:00
Joey Hess
ed0afbc36b
avoid concurrent threads trying to take pid lock at same time
Seem there are several races that happen when 2 threads run PidLock.tryLock
at the same time. One involves checkSaneLock of the side lock file, which may
be deleted by another process that is dropping the lock, causing checkSaneLock
to fail. And even with the deletion disabled, it can still fail, Probably due
to linkToLock failing when a second thread overwrites the lock file.

The same can happen when 2 processes do, but then one process just fails
to take the lock, which is fine. But with 2 threads, some actions where failing
even though the process as a whole had the pid lock held.

Utility.LockPool.PidLock already maintains a STM lock, and since it uses
LockShared, 2 threads can hold the pidlock at the same time, and when
the first thread drops the lock, it will remain held by the second
thread, and so the pid lock file should not get deleted until the last
thread to hold it drops the lock. Which is the right behavior, and why a
LockShared STM lock is used in the first place.

The problem is that each time it takes the STM lock, it then also calls
PidLock.tryLock. So that was getting called repeatedly and concurrently.

Fixed by noticing when the shared lock is already held, and stop calling
PidLock.tryLock again, just use the pid lock that already exists then.

Also, LockFile.PidLock.tryLock was deleting the pid lock when it failed
to take the lock, which was entirely wrong. It should only drop the side
lock.

Sponsored-by: Dartmouth College's Datalad project
2021-12-01 17:14:39 -04:00
Joey Hess
66b2536ea0
fix too early close of shared lock file
This fixes a reversion introduced in commit
ac56a5c2a0.

I didn't notice there that it was handling the case of a shared lock
file that was still open elsewhere by not running the close action.

This was especially deadly when annex.pidlock is set, as it caused early
deletion of the pid lock file.

Sponsored-by: Dartmouth College's Datalad project
2021-12-01 17:06:28 -04:00
Joey Hess
f50de2455f
retitle 2021-12-01 14:35:31 -04:00
Joey Hess
54a4ca9e3c
comment 2021-12-01 14:10:39 -04:00
Joey Hess
d4e99d902b
analysis 2021-12-01 13:38:47 -04:00
Joey Hess
b7976e08f0
comment 2021-12-01 13:03:05 -04:00
Joey Hess
e11ca04e28
comment 2021-12-01 12:46:07 -04:00
yarikoptic
7ca799efed initial report on needing more thorough retries when downloading from S3 2021-12-01 15:41:13 +00:00
account@dc612ad075297e574ebc3eb9a5b8ab6e753510dc
30c55f8940 Added a comment: Further fix attempts 2021-12-01 03:25:35 +00:00
adina.wagner@2a4cac6443aada2bd2a329b8a33f4a7b87cc8eff
a5b635af20 Added a comment: A few Windows benchmarks 2021-11-29 22:17:39 +00:00
Joey Hess
a6699be79d
catch error statting pid lock file if it somehow does not exist
It ought to exist, since linkToLock has just created it. However,
Lustre seems to have a rather probabilisitic view of the contents of a
directory, so catching the error if it somehow does not exist and
running the same code path that would be ran if linkToLock failed
might avoid this fun Lustre failure.

Sponsored-by: Dartmouth College's Datalad project
2021-11-29 14:53:07 -04:00
Joey Hess
567f63ba47
export: Avoid unncessarily re-exporting non-annexed files that were already exported
Commit b6e4ed9aa7 made non-annexed files
be re-uploaded every time, since they're not tracked in the location log,
and it made it check the location log. Don't do that for non-annexed files.

Sponsored-by: Brock Spratlen on Patreon
2021-11-29 14:02:38 -04:00
Joey Hess
05d79b26d8
clarify 2021-11-29 14:00:32 -04:00
Joey Hess
28cca9b9ff
comment 2021-11-29 13:32:12 -04:00
Joey Hess
357760cacf
comment 2021-11-29 13:16:52 -04:00
Joey Hess
b141b8a009
comment 2021-11-29 13:02:15 -04:00
Joey Hess
01a5ee6998
addurl, youtube-dl: When --check-raw prevents downloading an url, still continue with any downloads that come after it, rather than erroring out
Sponsored-By: Mark Reidenbach on Patreon
2021-11-28 19:40:06 -04:00
Joey Hess
9a1f14e6f0
Merge branch 'master' of ssh://git-annex.branchable.com 2021-11-26 10:32:22 -04:00
mih
02e3756bd7 Added a comment: Even more impact on real systems 2021-11-26 14:23:34 +00:00
Atemu
0f48796532 Added a comment 2021-11-25 19:23:46 +00:00
mih
120a94bcb8 Added a comment: More statistics 2021-11-25 13:09:11 +00:00
Rémi
0b2314ffe0 bug on export tree remote. 2021-11-25 10:15:49 +00:00
mih
fe143b2cb9 Added a comment: Translates to Windows! 2021-11-25 07:34:49 +00:00
dev@c1c358f0d3c8563701193b66791eb1bc57a25ac9
5aca043296 2021-11-24 21:01:41 +00:00
yarikoptic
e83c07427a 2021-11-24 14:13:20 +00:00
yarikoptic
574938c234 Added a comment 2021-11-23 23:22:36 +00:00
yarikoptic
65494a9f81 Added a comment 2021-11-23 23:12:47 +00:00
jkniiv
6d59508f02 Added a comment 2021-11-23 21:46:43 +00:00
Joey Hess
4703ad3e7f
remove unused import 2021-11-23 16:15:57 -04:00
Joey Hess
1d513540e9
Fix build with old versions of feed library 2021-11-23 16:06:51 -04:00