Skip to content
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

Error: the repository you want to access is already locked #1014

Open
arnaudlecam opened this issue Jan 30, 2023 · 9 comments · Fixed by #1030 · May be fixed by #1025
Open

Error: the repository you want to access is already locked #1014

arnaudlecam opened this issue Jan 30, 2023 · 9 comments · Fixed by #1030 · May be fixed by #1025

Comments

@arnaudlecam
Copy link

Hi,
Lauching Git Bug (v0.8.0) gives me this Error message:
Error: the repository you want to access is already locked by the process pid 1138
I don't have any 1138 PID running, and Git is working fine (Guitar, Gitk, etc.)
Is there a way to unlock ?

@MichaelMure
Copy link
Owner

If you are sure there is no other process, you can delete .git/git-bug/lock.

But realistically, only another git-bug process would put a lock there, which begs the question: if there really is no other process running, why does git-bug think so?

The corresponding code is there:

func IsRunning(pid int) bool {

Admittedly, there is a TODO that could explain your problem, but you are the first one to report a problem with that.

@arnaudlecam
Copy link
Author

Sorry, finally I made a reboot : it works now, but I don't know how to reproduce... So issue could be closed.
I'll try a few tests, and then I'll send you a feedback if it succeeds.

@arnaudlecam
Copy link
Author

arnaudlecam commented Feb 2, 2023

Here I reproduced:
First, you run git-bug: here .git/git-bug/lock contains the PID (ex.: 1322).
The save all your works and close all youre running tasks (but you don't close git-bug).
Now if you hard-reboot (pressing "Off" button a long time) while running git-bug, then git-bug is killed and .git/git-bug/lock isn't deleted (containing the killed PID: 1322).
Now you reboot, but you don't start with git-hub : you run another programms and don't close them, until those PID's are greater than the killed PID (ex.: you can launch chromium and open a large number of tabs).
With (un)luck, it will open a process with the same PID (1322).
Then you launch git-hub, and it's reproduced (ex.: Error: the repository you want to access is already locked by the process pid 1322).
The first time I reported it, I was realy unlucky: after hard-reboot, I think the "killed PID" was owned by a system's process so it wasn't listed with ps -e.
May it should test the PID's name to ? If the PID is found, then we check this PID's name. And if the PID's name is "git-bug", then git-bug isn't launched, else git-bug could be launched.

@arnaudlecam arnaudlecam reopened this Feb 2, 2023
@MichaelMure
Copy link
Owner

That's a very good point. I suppose we need a reliable and multi-platform way to check that the running process is indeed git-bug. Now, how to do that ...

@arnaudlecam
Copy link
Author

May process.Name or process.NameWithContext should do the trick ?
But sorry, I never wrote a Go line: you should be more efficient than me ;-)

@MichaelMure
Copy link
Owner

I'm busy with other things, so anyone would be faster than that :-)

@smoyer64
Copy link
Collaborator

That's a pretty crazy path to a bug - I'm running Linux so I never hard kill anything (or reboot for that matter). What OS are you running and when you say that you start git-bug but don't close it, do you mean termui or webui (running the git-bug CLI should stop on it's own and delete the lock file).

@smoyer64
Copy link
Collaborator

I did a bit of testing (Xubuntu Linux 22.04) and found that the lock file is not always removed when I would have expected:

Signal TermUI WebUI
SIGINT Removed Removed
SIGTERM Removed Not removed
SIGKILL Not removed Not removed

I wouldn't expect that we can capture SIGKILL but the webui could be enhanced to cleanly shut down on SIGTERM. Note that it's also possible that the longer running CLI processes (e.g. bridge pull) could leave a lock file behind when killed so I think the idea of checking that the process is in fact git-bug is a good idea.

@arnaudlecam
Copy link
Author

That's a pretty crazy path to a bug - I'm running Linux so I never hard kill anything (or reboot for that matter). What OS are you running and when you say that you start git-bug but don't close it, do you mean termui or webui (running the git-bug CLI should stop on it's own and delete the lock file).

I'm runnig Linux (6.1.12-arch1-1), using termui. I understand your comment about that "crazy path to a bug": first time I reported this issue, my computer has halted with a power breakdown. I suppose it can be a "real case", so hardrebooted to try reproduce and reporting it as an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants