-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Improve error when can't acquire db lock #13340
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,7 +221,16 @@ LocalStore::LocalStore(ref<const Config> config) | |
| schema upgrade is in progress. */ | ||
| if (!config->readOnly) { | ||
| Path globalLockPath = dbDir + "/big-lock"; | ||
| globalLock = openLockFile(globalLockPath.c_str(), true); | ||
| try { | ||
| globalLock = openLockFile(globalLockPath.c_str(), true); | ||
| } catch (SysError & e) { | ||
| if (e.errNo == EACCES || e.errNo == EPERM) { | ||
| e.addTrace({}, | ||
| "This command may have been run as non-root in a single-user Nix installation,\n" | ||
| "or the Nix daemon may have crashed."); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would a daemon crash cause this issue?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had gleaned that from open issues, although maybe that's no longer the case? I just tried e.g. this reproducer and didn't get the error #3435 (comment)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do see the error if I |
||
| } | ||
| throw; | ||
| } | ||
| } | ||
|
|
||
| if (!config->readOnly && !lockFile(globalLock.get(), ltRead, false)) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by the tense ("may have been") here. Is the current command being run as non-root, or was a previous command run as non-root?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the current command
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could probably also check check "isNonRootuser()" to make a more concrete error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in the general case where the file isn't owned by the current uid, we can add the hint that maybe you wanted to connect to a nix daemon instead.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could say "you may want to start a Nix daemon", but the user doesn't really connect to the Nix daemon themselves so I don't think "you may want to connect to a Nix daemon instead" would be very helpful, because it's not actionable. Did you have something in mind?