refactor: Avoid locking tx pool cs thrice#13786
Merged
maflcko merged 1 commit intobitcoin:masterfrom Jul 30, 2018
Merged
Conversation
Contributor
Note to reviewers: This pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
faf2eca to
fa6b4b5
Compare
fa6b4b5 to
fa5ed4f
Compare
Member
Author
|
Rebased |
Empact
reviewed
Jul 30, 2018
|
|
||
|
|
||
| CTxMemPool testPool; | ||
| LOCK(testPool.cs); |
Contributor
There was a problem hiding this comment.
nit: could move to 65 since removeRecursive locks separately
Empact
reviewed
Jul 30, 2018
| { | ||
| CBlockPolicyEstimator feeEst; | ||
| CTxMemPool mpool(&feeEst); | ||
| LOCK(mpool.cs); |
Contributor
|
utACK fa5ed4f |
kallewoof
reviewed
Jul 30, 2018
maflcko
pushed a commit
to maflcko/bitcoin-core
that referenced
this pull request
Jul 30, 2018
fa5ed4f refactor: Avoid locking tx pool cs thrice (MarcoFalke) Pull request description: `addUnchecked` is (outside the tests) only called by ATMP, which already takes the tx pool read lock. So locking it twice more in both `addUnchecked` methods seems redundant. Similarly `CalculateMemPoolAncestors` is (beside once in the wallet) only called in contexts, where the tx pool lock is already taken. So remove the lock there as well. Tree-SHA512: fcf603b570da0fc529fe6db8add218663eae52845510732bee0d4611263d2429d3d3c9c8ae68493d67287d13504500ed51905ccbe711eb15a0af3b019edad543
jasonbcox
pushed a commit
to Bitcoin-ABC/bitcoin-abc
that referenced
this pull request
Oct 11, 2019
Summary: `addUnchecked` is (outside the tests) only called by ATMP, which already takes the tx pool read lock. So locking it twice more in both `addUnchecked` methods seems redundant. Backport of Bitcoin Core PR13786 bitcoin/bitcoin#13786 Test Plan: 1. Build with Clang in Debug mode: ``` CXX=clang++ CC=clang cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug ninja check ``` 2. Verify that the compiler has not emitted a `thread-safety` warning. 3. Run the node: `./src/bitcoind -regtest` 4. Verify that text similar to `"Assertion failed: lock ... not held ..."` is not printed on `stderr`. Reviewers: Fabien, #bitcoin_abc, deadalnix Reviewed By: Fabien, #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D4186
PastaPastaPasta
pushed a commit
to PastaPastaPasta/dash
that referenced
this pull request
Feb 4, 2021
fa5ed4f refactor: Avoid locking tx pool cs thrice (MarcoFalke) Pull request description: `addUnchecked` is (outside the tests) only called by ATMP, which already takes the tx pool read lock. So locking it twice more in both `addUnchecked` methods seems redundant. Similarly `CalculateMemPoolAncestors` is (beside once in the wallet) only called in contexts, where the tx pool lock is already taken. So remove the lock there as well. Tree-SHA512: fcf603b570da0fc529fe6db8add218663eae52845510732bee0d4611263d2429d3d3c9c8ae68493d67287d13504500ed51905ccbe711eb15a0af3b019edad543
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
addUncheckedis (outside the tests) only called by ATMP, which already takes the tx pool read lock. So locking it twice more in bothaddUncheckedmethods seems redundant.Similarly
CalculateMemPoolAncestorsis (beside once in the wallet) only called in contexts, where the tx pool lock is already taken. So remove the lock there as well.