TheBlueMatt
commented at 6:54 PM on February 6, 2018:
member
This resolves an issue where getrawmempool() can race mempool
notification signals. Intuitively we use mempool.cs as a "read
lock" on the mempool with cs_main being the write lock, so holding
the read lock intermittently while doing write operations is
somewhat strange.
This also avoids the introduction of cs_main in getrawmempool()
which reviewers objected to in the previous fix in #12273
Hold mempool.cs for the duration of ATMP.
This resolves an issue where getrawmempool() can race mempool
notification signals. Intuitively we use mempool.cs as a "read
lock" on the mempool with cs_main being the write lock, so holding
the read lock intermittently while doing write operations is
somewhat strange.
This also avoids the introduction of cs_main in getrawmempool()
which reviewers objected to in the previous fix in #12273
85aa8398f5
MarcoFalke added this to the milestone 0.16.0 on Feb 6, 2018
MarcoFalke
commented at 7:22 PM on February 6, 2018:
member
Thanks, fixes the test failures for me. (At least the wallet and mempool related ones, heh)
Add braces to meet code style on line-after-the-one-changed.02fc886363
MarcoFalke added the label Needs backport on Feb 6, 2018
MarcoFalke
commented at 9:15 PM on February 6, 2018:
member
re-utACK02fc8863630a20e75230f8bc3ba1051c480ae560 (second commit obviously not for backport)
promag
commented at 10:20 PM on February 6, 2018:
member
I don't think this is correct because of lock order. You correctly say
// mempool "read lock" (held through GetMainSignals().TransactionAddedToMempool())
And when it hits CWallet::TransactionAddedToMempool the lock order will be cs_main, mempool.cs, cs_wallet.
But, for instance, listtransactions RPC when eventually reaches WalletTxToJSON, the lock order will be cs_main, cs_wallet, mempool.cs.
Correct me if I'm wrong, but can't this create a deadlock?
TheBlueMatt
commented at 10:24 PM on February 6, 2018:
member
There is no lock order across TransactionAddedToMempool as it is called on a background thread (and can wait as long as it wants).
promag
commented at 10:34 PM on February 6, 2018:
member
Right, GetMainSignals().TransactionAddedToMempool enqueues the signal!
utACK02fc886.
sipa
commented at 3:21 AM on February 7, 2018:
member
utACK02fc8863630a20e75230f8bc3ba1051c480ae560. We probably want to rethink how locking of chainstate/mempool works later on (either by using actual rwlocks, or by allowing the mempool to lag behind chain validation).
devrandom
commented at 5:27 PM on February 7, 2018:
none
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me