-
Notifications
You must be signed in to change notification settings - Fork 285
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(core-transaction-pool): rebuild vs update race #3800
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 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
ghost
added
Complexity: High
labels
Jun 15, 2020
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
faustbrian
deleted the
fix/core-transaction-pool/fix-rebuild-vs-update-race
branch
June 15, 2020 05:57
2 tasks
ghost
mentioned this pull request
Jun 21, 2020
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
, andcleanUp
are update operations evolving pool.flush
andreaddTransactions
are rebuild operations that work on pool as a whole.These two kind of operations cannot happen simultaneously. The key difference is that
flush
andreaddTransaction
are wiping mempool, storage, and in general require full rebuild of senders wallet repositories.While
addTransaction
,removeTransaction
,acceptForgedTransaction
, andcleanUp
were synchronized on sender level, they were not synchronized withflush
andreaddTransactions
. 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
, andcleanUp
to execute in parallel, butreaddTransactions
andflush
to lock pool completely until finished:readdTransactions
andflush
set themself intorebuildLock
.addTransaction
,removeTransaction
,acceptForgedTransaction
, andcleanUp
wait forrebuildLock
before adding themself intoupdateLocks
readdTransactions
andflush
wait for any pendingupdateLocks
to finish before touching storage or mempool.Checklist