-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why not automatically remove stale lock directories? #30
Comments
|
Perhaps the following wrapper script (to run bitpocket on the slave), can be enhanced to handle Ctrl-C interrupts? Run it with the synced folder as the first argument. #! /usr/bin/env bash cd $1 sleep $[ ( $RANDOM % 300 ) ]s #Reduce collisions with other slaves trying to sync simultaneously. if [ -e "${PIDFILE}" ] && (ps -u rm -rf .bitpocket/tmp/lock #Previously spawned proc is now dead. There should be no lock at this point. This step corrects for an unclean shutdown. echo Edit: Actually this is already taken care of in the next run of the script. |
@LucasTx thinking about why not to remove stale locks automatically... and I can't remember any good reason at the moment. I'll take a look at test cases and the script itself and will try to figure out if there's any danger in automatic removal. |
Well, I remember now. The stale local lock signals that previous sync didn't finish with success. I am not sure if we can just run another sync without user first checking if the files/directories are looking fine after previous unsuccessful sync. Yeah, so the purpose was to block next sync and require user to "unblock" it by remove the lock manually. Do you think the default behavior should be changed? Also, maybe we can just add "-f" flag to force sync with automatic lock removal. |
The "-f" flag option seems to be the best option, as it will keep the On Wed, Jan 9, 2013 at 6:18 PM, Marcin Kulik notifications@github.comwrote:
|
The current version of bitpocket spits out a command that the user can run to remove the lock file, making everything very simple but also transparent. It does not remove the lock file on the server. To close this issue, it seems that there are two things needed:
|
I think we should look to make this an automatic process or otherwise write something to stderr so that the crontab system will send me a mail when the sync breaks. Otherwise the sync may stop running for a number of days before I notice. |
I've implemented the |
Whenever a
sync
is interrupted (e.g. manually with Ctrl-C), the lock directory is left behind, with a file containing the PID of the process that created it.When it tries to sync again, the function
acquire_lock
tries to kill the process with this PID, and if it fails (i.e. the process does not exist), it exits with this error message:There's stale lock directory at <LOCK_DIR>. Please remove it and try again.
Why not remove the lock directory directly in the script, instead of asking the user, if it is known to be stale?
Is there a case in which there is a stale directory but removing it could be harmful?
The text was updated successfully, but these errors were encountered: