-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Deadlock when updating keys while iterating over them #315
Comments
I believe the issue seems to be the callback, that releases the rlock on the logFile, put into the transaction callbacks here https://github.com/dgraph-io/badger/blob/master/iterator.go#L84 is not called before calling batchSet here https://github.com/dgraph-io/badger/blob/master/transaction.go#L411 which sometimes asks for the lock again here https://github.com/dgraph-io/badger/blob/master/value.go#L130 |
You have an You could avoid this by two things:
I'm seeing users getting stuck with this issue repeatedly. So, it would make sense to have another function on We also need to have a warning about this behavior in the README. |
I'm also seeing this issue occuring outside of iterators, rarely (but not so rarely in my use case) calling Value() on Item and then updating it in the same transaction, I'm a bit too tired to make a minimal reproducable case right now but i can get to it in the morning probably. |
This pending PR would add a Update: @jonas747 Can you run with my PR and check if you still see any deadlocks using the new |
It dosen't seem to happen anymore as far as i can see after using ValueCopy, but if i can make a request, it would be nice if we could pass our own say io.Writer so we could reuse that buffer. |
Just pushed another commit, which modifies the function to accept a byte slice, where the data would be written. |
The commit is in b3568eb. @deepakjois would cut a release branch sometime soon. Documentation is updated. Marking this issue as closed. |
I don't see it stated anywhere that updating values while iterating isn't supported, so i'm assuming i'm not doing anything wrong?
Using the latest git version as of typing.
Running the following for a while (usually 10 seconds for me) will cause a deadlock (when the counter stays at 0 every second):
The text was updated successfully, but these errors were encountered: