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 race in view iteration #2486

Merged
merged 7 commits into from
Dec 14, 2023
Merged

Fix race in view iteration #2486

merged 7 commits into from
Dec 14, 2023

Conversation

dboehm-avalabs
Copy link
Contributor

Avoids race when reading view.invalidated or view.db.closed during iteration

@danlaine
Copy link

As an alternative, would it make sense to invalidate all the children of the database on Close(), and remove the check for the database being closed in the iterator?

@dboehm-avalabs
Copy link
Contributor Author

As an alternative, would it make sense to invalidate all the children of the database on Close(), and remove the check for the database being closed in the iterator?

Yeah, that would be a fair change too

return database.ErrClosed
}

db.closed.Set(true)
// mark all children as no longer valid because the db has closed
db.invalidateChildrenExcept(nil)

Choose a reason for hiding this comment

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

Can we add a unit test for this? Otherwise LGTM

@dboehm-avalabs dboehm-avalabs added this pull request to the merge queue Dec 14, 2023
Merged via the queue into dev with commit f887e48 Dec 14, 2023
17 checks passed
@dboehm-avalabs dboehm-avalabs deleted the FixRaceInViewIteration branch December 14, 2023 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants