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 IAVL Iterator Race Condition #5279

Merged
merged 3 commits into from
Nov 6, 2019
Merged

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Nov 5, 2019

closes: #5276
credit: @wangkui0508 🎉


  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md

  • Re-reviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

func (iter *iavlIterator) Close() {
close(iter.quitCh)
// wait iterCh to close
for range iter.iterCh {
Copy link
Contributor Author

@alexanderbez alexanderbez Nov 5, 2019

Choose a reason for hiding this comment

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

See comment in the original issue. I believe we can alternatively wait on a done channel that gets sent during iterateRoutine(). But I think this will also suffice.

In addition, not sure how to best test this as I imagine we'll need a large tree to have iterateRoutine still run after we call Close().

Choose a reason for hiding this comment

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

Use go test -race in unit test may make this bug happen. But it does not always happen.

@codecov
Copy link

codecov bot commented Nov 5, 2019

Codecov Report

Merging #5279 into master will decrease coverage by <.01%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           master    #5279      +/-   ##
==========================================
- Coverage    53.5%   53.49%   -0.01%     
==========================================
  Files         290      290              
  Lines       17770    17771       +1     
==========================================
  Hits         9507     9507              
  Misses       7513     7513              
- Partials      750      751       +1

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

utACK

@alexanderbez alexanderbez merged commit 60c4f5c into master Nov 6, 2019
@alexanderbez alexanderbez deleted the bez/5276-fix-iavl-iter-close branch November 6, 2019 13:52
@alexanderbez alexanderbez mentioned this pull request Dec 19, 2019
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in iavlIterator.Close() can cause race condition (store/iavl/store.go)
3 participants