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 concurrent database access when deleting orphans #219

Merged
merged 2 commits into from
Mar 13, 2020

Conversation

erikgrinaker
Copy link
Contributor

When deleting orphans, an orphan node is deleted from the database while the database is being iterated over. This breaks the tm-db contract:

CONTRACT: No writes may happen within a domain while an iterator exists over it.

This caused deadlocks and race conditions with the new B-tree based MemDB.

I believe this is an oversight, since all of the other related writes are batched in snapshotBatch or recentBatch instead of writing directly to the database. This change fixes the problem by batching the deletes instead. The tests pass, but I would like a confirmation from someone familiar with this logic.

@erikgrinaker erikgrinaker self-assigned this Mar 10, 2020
@tac0turtle tac0turtle added the T:bug Type: Bug (Confirmed) label Mar 10, 2020
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

lgtm, but not familiar with the code

Copy link
Member

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

Makes sense, good catch!

@erikgrinaker erikgrinaker merged commit 17428bb into master Mar 13, 2020
@erikgrinaker erikgrinaker deleted the erik/delete-orphans-race branch March 13, 2020 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T:bug Type: Bug (Confirmed)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants