-
Notifications
You must be signed in to change notification settings - Fork 63
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
"failed to lock file" error #205
Comments
Hmmm, this is an interesting case. Thanks for reporting it, @larsks. There is one place in StGit's transaction code where the stack reference (e.g. I'll note that it seems possible to ensure locks are cleaned up with a SIGTERM, but not with a SIGKILL and/or other arbitrary exit conditions. Also, not sure what mechanisms are available on Windows since that platform doesn't really do signals. |
Here's a complete reproducer for this situation. PrerequisitesYou need git configured to automatically sign commits.
You need gpg configured to prompt for a passphrase on the terminal:
Initial repository stateWe start with:
Procedure
|
This reproducing procedure is really helpful. I am able to reproduce the problem and have started taking a look at what's going on. |
When gpg signatures (stgit.gpgsign and/or commit.gpgsign) are enabled, there is an opportunity for commits occurring at stack transaction execute time to fail due to gpg failing. And gpg may fail for any number of reasons, but some likely ones are either the user entering the wrong pass phrase too many times or the user simply cancelling pass phrase entry. In these cases where a transaction-time commit might fail, StGit should leave the repository, working tree, and stack in a consistent state. But as issue #205 demonstrates, there have been some problems where repo, working tree, and stack state have not been consistent after such a failure. This new test case exercises a known-problematic code path. Reproduces #205.
Edit: Hey, thanks for taking the time to look at this and address it! Those changes seem to successfully clear up the locking problem. With the changes in 08b0bd4, the above procedure still leaves the local repository in an inconsistent state:
Is that the intended behavior? |
For the case where |
I was just following the earlier procedure for reproducing the original problem. Here's a complete log:
|
I am able to reproduce the above when I configure gpg with
So there is something about hitting ctrl-c with the loopback pinentry that seems to cause the parent |
The |
The updated transaction rollback code currently assumes that the subordinate |
When the user sends a SIGINT signal (i.e. by pressing ctrl-c) while the stack transaction is executing, the signal is now deferred such that the rollback can occur as it does for other transaction execute time errors. SIGINT signals outside of the execute-time critical section are not deferred and will cause the stg process to exit immediately. The implementation uses the ctrlc crate, which is cross platform and should also work on Windows. Also add test case that simulates the stg process being hit with a SIGINT at transaction execute time, which is a thing that can happen depending on the gpg pinentry configuration and if the user hits ctrl-c. N.B. this change only handles SIGINT. The more violent SIGKILL will immediately terminate the stg process, bypassing the rollback mechanism. Fixes: #205
I accidentally aborted an
stg goto
operation (configured to gpg sign commits by default, fingers didn't anticipate the password prompt so I typed the wrong thing, causing the commit to fail, causing stg to fail), and subsequentstg
operations failed with:Removing the lock file allowed things to continue, but this seems like a bug: stg should clean up lockfiles on exit, and even if it fails to clean up lock files, any locks it holds shouldn't persist when the process exits.
The text was updated successfully, but these errors were encountered: