-
Notifications
You must be signed in to change notification settings - Fork 280
fix(core-transaction-pool): rebuild vs update race #3800
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
Merged
faustbrian
merged 15 commits into
develop
from
fix/core-transaction-pool/fix-rebuild-vs-update-race
Jun 15, 2020
Merged
fix(core-transaction-pool): rebuild vs update race #3800
faustbrian
merged 15 commits into
develop
from
fix/core-transaction-pool/fix-rebuild-vs-update-race
Jun 15, 2020
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## develop #3800 +/- ##
============================================
+ Coverage 86.39% 96.92% +10.53%
============================================
Files 616 616
Lines 13925 13999 +74
Branches 1686 1688 +2
============================================
+ Hits 12030 13569 +1539
+ Misses 1538 137 -1401
+ Partials 357 293 -64
Continue to review full report at Codecov.
|
faustbrian
approved these changes
Jun 15, 2020
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
There are two kind of operations executed in pool:
addTransaction,removeTransaction,acceptForgedTransaction, andcleanUpare update operations evolving pool.flushandreaddTransactionsare rebuild operations that work on pool as a whole.These two kind of operations cannot happen simultaneously. The key difference is that
flushandreaddTransactionare wiping mempool, storage, and in general require full rebuild of senders wallet repositories.While
addTransaction,removeTransaction,acceptForgedTransaction, andcleanUpwere synchronized on sender level, they were not synchronized withflushandreaddTransactions. This caused problem in entity transaction handler after pool started handling milestone change. I wasn't able to pinpoint the actual race cause, but got rough idea what sequence of events caused it:In general solution is to allow
addTransaction,removeTransaction,acceptForgedTransaction, andcleanUpto execute in parallel, butreaddTransactionsandflushto lock pool completely until finished:readdTransactionsandflushset themself intorebuildLock.addTransaction,removeTransaction,acceptForgedTransaction, andcleanUpwait forrebuildLockbefore adding themself intoupdateLocksreaddTransactionsandflushwait for any pendingupdateLocksto finish before touching storage or mempool.Checklist