Skip to content

Commit a2cf77d

Browse files
committed
fix rechecktx idling when mempool is empty
1 parent 74157e3 commit a2cf77d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

mempool/clist_mempool.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,10 +706,6 @@ func (mem *CListMempool) purgeExpiredTxs(blockHeight int64, blockTime time.Time)
706706
func (mem *CListMempool) recheckTxs() {
707707
mem.logger.Debug("recheck txs", "height", mem.height.Load(), "num-txs", mem.Size())
708708

709-
if mem.Size() <= 0 {
710-
return
711-
}
712-
713709
for e := mem.txs.Front(); e != nil; e = e.Next() {
714710
memTx := e.Value.(*mempoolTx)
715711
// If this transaction is Cosmos transaction containing a
@@ -721,6 +717,14 @@ func (mem *CListMempool) recheckTxs() {
721717
}
722718
}
723719
}
720+
721+
// If the mempool is empty after removing short-term CLOB transactions, there will be no
722+
// recheck responses sent by the app, so waiting on mem.recheck.doneRechecking() would
723+
// block until mem.config.RecheckTimeout elapses. Early-return here avoids that idle wait.
724+
if mem.Size() <= 0 {
725+
return
726+
}
727+
724728
mem.recheck.init(mem.txs.Front(), mem.txs.Back())
725729

726730
// NOTE: globalCb may be called concurrently, but CheckTx cannot be executed concurrently

0 commit comments

Comments
 (0)