git-annex/doc/bugs/Stale_lock_files_on_Android.mdwn
Joey Hess 635c9a1549 assistant: Detect stale git lock files at startup time, and remove them.
Extends the index.lock handling to other git lock files. I surveyed
all lock files used by git, and found more than I expected. All are
handled the same in git; it leaves them open while doing the operation,
possibly writing the new file content to the lock file, and then closes
them when done.

The gc.pid file is excluded because it won't affect the normal operation
of the assistant, and waiting for a gc to finish on startup wouldn't be
good.

All threads except the webapp thread wait on the new startup sanity checker
thread to complete, so they won't try to do things with git that fail
due to stale lock files. The webapp thread mostly avoids doing that kind of
thing itself. A few configurators might fail on lock files, but only if the
user is explicitly trying to run them. The webapp needs to start
immediately when the user has opened it, even if there are stale lock
files.

Arranging for the threads to wait on the startup sanity checker was a bit
of a bear. Have to get all the NotificationHandles set up before the
startup sanity checker runs, or they won't see its signal. Perhaps
the NotificationBroadcaster is not the best interface to have used for
this. Oh well, it works.

This commit was sponsored by Michael Jakl
2013-10-05 17:04:21 -04:00

44 lines
1.6 KiB
Markdown

### Please describe the problem.
Both my Android devices where not processing git-annex updates due to stale lock files. While the lock files are different, I've reported them both together as they are related.
### What steps will reproduce the problem?
Unknown, perhaps the assistant crashed, or the battery ran flat on them.
To resolve the issue I had to manually remove the lock files.
### What version of git-annex are you using? On what operating system?
On my Android phone, daily build 4.20130614-g221aea4
On my Android tablet, daily build 4.20130621-g36258de
### Please provide any additional information below.
It seems to me that it'd be useful to have the assistant check to see if the lock files are still valid and remove them if they're stale.
[[!format sh """
# If you can, paste a complete transcript of the problem occurring here.
# If the problem is with the git-annex assistant, paste in .git/annex/daemon.log
My phone:
From ssh://git-annex-flick-andrewannex_phonecamera/~/phone-camera
987dc25..682cdd1 git-annex -> flick_phonecamera/git-annex
fatal: Unable to create '/storage/emulated/legacy/DCIM/.git/refs/remotes/flick_phonecamera/synced/git-annex.lock': File exists.
My tablet:
Committer: Adding Coleman-C..eedom.pdf
Committer: Committing changes to git
fatal: Unable to create '/mnt/sdcard/reference/.git/index.lock': File exists.
# End of transcript or log.
"""]]
> The '/mnt/sdcard/reference/.git/index.lock' lock file will now be
> automatically dealt with. Have not done anything about the refs/remotes
> lock files yet. --[[Joey]]
>
> Now the assistant deals with all stale git lock files on startup.
> [[done]] --[[Joey]]