diff --git a/mempool/v1/mempool.go b/mempool/v1/mempool.go index 2e83dc74b..d04fe1ad3 100644 --- a/mempool/v1/mempool.go +++ b/mempool/v1/mempool.go @@ -129,7 +129,18 @@ func (txmp *TxMempool) SizeBytes() int64 { return atomic.LoadInt64(&txmp.txsByte // // The caller must hold an exclusive mempool lock (by calling txmp.Lock) before // calling FlushAppConn. -func (txmp *TxMempool) FlushAppConn() error { return txmp.proxyAppConn.FlushSync() } +func (txmp *TxMempool) FlushAppConn() error { + // N.B.: We have to issue the call outside the lock so that its callback can + // fire. It's safe to do this, the flush will block until complete. + // + // We could just not require the caller to hold the lock at all, but the + // semantics of the Mempool interface require the caller to hold it, and we + // can't change that without disrupting existing use. + txmp.mtx.Unlock() + defer txmp.mtx.Lock() + + return txmp.proxyAppConn.FlushSync() +} // EnableTxsAvailable enables the mempool to trigger events when transactions // are available on a block by block basis.