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

fix(writeBatch): Avoid deadlock in commit callback #1529

Merged
merged 2 commits into from
Sep 27, 2020

Conversation

jarifibrahim
Copy link
Contributor

@jarifibrahim jarifibrahim commented Sep 20, 2020

wb.Flush() would call wb.commit() while holding lock which would call
wb.callback in case of an error while committing.

wb.callback would try to acquire the lock wb.Flush is holding and this
would lead to a deadlock. This PR fixes it.

The test in this PR fails on master.


This change is Reviewable

wb.Flush() would call wb.commit() while holding lock which would call
wb.callback in case of an error while committing.
wb.callback would try to acquire the lock wb.Flush is holding and this
would lead to a deadlock. This PR fixes it.
Copy link
Contributor

@NamanJain8 NamanJain8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@jarifibrahim jarifibrahim merged commit 0ce7331 into master Sep 27, 2020
@jarifibrahim jarifibrahim deleted the ibrahim/wb-deadloack branch September 27, 2020 10:15
jarifibrahim pushed a commit that referenced this pull request Oct 2, 2020
wb.Flush() would call wb.commit() while holding lock which would call
wb.callback in case of an error while committing.
wb.callback would try to acquire the lock wb.Flush is holding and this
would lead to a deadlock. This PR fixes it.
mYmNeo added a commit to mYmNeo/badger that referenced this pull request Jan 17, 2023
mYmNeo added a commit to mYmNeo/badger that referenced this pull request Feb 13, 2023
mYmNeo added a commit to mYmNeo/badger that referenced this pull request Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants