-
Notifications
You must be signed in to change notification settings - Fork 42
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
Locked index error #62
Comments
Range of fixes
|
This was inspired by running into errors where `cargo add inquire` was not adding the latest version. We've seen similar problems during the development of `crates-index`, so hoping what they've done fixes this. Even if it doesn't solve this problem, hopefully by nature of using a shared crate means it will get more use and more eyes to make it more reliable in the long term. Handling retrying the index is annoying. I opened frewsxcv/rust-crates-index#62 Note: in the next version of crates-index - Opening an index will implicitly create it, so we won't be able to differentiate in our message whether we are initializing or updating. See frewsxcv/rust-crates-index#61 - We will be able to open an Index by URL, which will allow us to remove more logic
This was inspired by running into errors where `cargo add inquire` was not adding the latest version. We've seen similar problems during the development of `crates-index`, so hoping what they've done fixes this. Even if it doesn't solve this problem, hopefully by nature of using a shared crate means it will get more use and more eyes to make it more reliable in the long term. Handling retrying the index is annoying. I opened frewsxcv/rust-crates-index#62 Note: in the next version of crates-index - Opening an index will implicitly create it, so we won't be able to differentiate in our message whether we are initializing or updating. See frewsxcv/rust-crates-index#61 - We will be able to open an Index by URL, which will allow us to remove more logic
This was inspired by running into errors where `cargo add inquire` was not adding the latest version. We've seen similar problems during the development of `crates-index`, so hoping what they've done fixes this. Even if it doesn't solve this problem, hopefully by nature of using a shared crate means it will get more use and more eyes to make it more reliable in the long term. Handling retrying the index is annoying. I opened frewsxcv/rust-crates-index#62 Note: in the next version of crates-index - Opening an index will implicitly create it, so we won't be able to differentiate in our message whether we are initializing or updating. See frewsxcv/rust-crates-index#61 - We will be able to open an Index by URL, which will allow us to remove more logic
This was inspired by running into errors where `cargo add inquire` was not adding the latest version. We've seen similar problems during the development of `crates-index`, so hoping what they've done fixes this. Even if it doesn't solve this problem, hopefully by nature of using a shared crate means it will get more use and more eyes to make it more reliable in the long term. Handling retrying the index is annoying. I opened frewsxcv/rust-crates-index#62 Note: in the next version of crates-index - Opening an index will implicitly create it, so we won't be able to differentiate in our message whether we are initializing or updating. See frewsxcv/rust-crates-index#61 - We will be able to open an Index by URL, which will allow us to remove more logic
just adding this for future context. I did a bit of digging and i think this could arise from the fact that the underlying git2-rs crate uses I have no idea if this would work but perhaps this could also partially be solved by creating some kind of |
I assume the lock is on the filesystem level. I could add a |
Tried to look into this a bit. Again as I said this is a bit beyond me but here is what I understand of it: Firstly, about the file locking. What I understand is that there are two kinds of file locking. Advisory and Mandatory. While an advisory lock is acquired, other processes are still free to read or write the file if they are unaware of locks. However, every bit of documentation I found on Mandatory locking advises to not use it as it has to be enforced by the kernel, so I'm going to guess that any file locking done in these contexts is advisory. Getting a definite answer on this would mean digging into the actual C implementation of the underlying git library and I am not really comfortable doing that, so unless someone more knowledgable than me can comment on that I'm going to run with this idea. However, from what I have seen, file locks are assumed to be process specific anyway, so if we can guarantee consistence within out About it occurring only in testing, that is hard for me to judge accurately since I didn't actually see the errors myself, but I did find this bug referenced in a bunch of downstream libraries such as Finally about the deadlocking. |
I think this should be fixed by now and I'd appreciated if the issue could be re-evaluated against v2.0. Thank you. |
So Also, it sounds like these locks are library specific, so a mixture of |
No, As you point out, the solution isn't universal, and can't ever be universal, so probably If this assessment is correct, two actions could follow:
What do you think? |
My priorities are
For myself, I care less about locking for maintaining a consistent view of the data |
Thank you! I went with option 2: "Document it in the API" which now makes clear that opening an index isn't safe in concurrent contexts due to the implicit auto-cloning. These improvements will be released within the hour. Further, I think this issue is resolved with |
The "document in the API" solution was specifically for documenting the expectation for retrying and how to do so. Yes, concurrent access is less likely to happen but I don't think this is something that should be punted to the caller. We have multiple process that could potentially be accessing a shared git repo. Putting the burden for avoiding corrupting the files on disk onto the user seems like a recipe for disaster as most won't notice and everyone will do it differently, meaning there will effectively be no protection. Whether we get implicit blocking or a documented error for "try again", we should be safe from corrupting data. |
I see! I just tried to see what kind of errors I see if there is a race just across
|
That would work for me |
I was swapping out
git fetch
withcrates-index
incargo-edit
and got test failures due to locked index.While its suspicious this was being updating during tests, it highlights that callers need to handle concurrent access. This is not obvious from the API.
The text was updated successfully, but these errors were encountered: