Skip to content
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

Bring back stop recheck #118

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions mempool/v0/clist_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ type CListMempool struct {
// Track whether we're rechecking txs.
// These are not protected by a mutex and are expected to be mutated in
// serial (ie. by abci responses which are called in serial).
recheckCursor *clist.CElement // next expected response
recheckEnd *clist.CElement // re-checking stops here
isRechecking atomic.Bool // true iff the rechecking process has begun and is not yet finished
recheckFull atomic.Bool // whether rechecking TXs cannot be completed before a new block is decided
recheckCursor *clist.CElement // next expected response
recheckEnd *clist.CElement // re-checking stops here
isRechecking atomic.Bool // true iff the rechecking process has begun and is not yet finished
recheckFull atomic.Bool // whether rechecking TXs cannot be completed before a new block is decided
stopRechecking atomic.Bool // true iff the rechecking process has begun and is not yet finished

// Map for quick access to txs to record sender in CheckTx.
// txsMap: txKey -> CElement
Expand Down Expand Up @@ -149,6 +150,7 @@ func (mem *CListMempool) PreUpdate() {
if rechecking != recheckFull {
mem.logger.Debug("the state of recheckFull has flipped")
}
mem.stopRechecking.Store(true)
}

// Safe for concurrent use by multiple goroutines.
Expand Down Expand Up @@ -673,6 +675,7 @@ func (mem *CListMempool) Update(
}

func (mem *CListMempool) recheckTxs() {
mem.stopRechecking.Store(false)
if mem.Size() == 0 {
panic("recheckTxs is called, but the mempool is empty")
}
Expand All @@ -684,13 +687,18 @@ func (mem *CListMempool) recheckTxs() {
// Push txs to proxyAppConn
// NOTE: globalCb may be called concurrently.
for e := mem.txs.Front(); e != nil; e = e.Next() {
if mem.stopRechecking.Load() {
break
}

memTx := e.Value.(*mempoolTx)
mem.proxyAppConn.CheckTxAsync(abci.RequestCheckTx{
Tx: memTx.tx,
Type: abci.CheckTxType_Recheck,
})
}

mem.stopRechecking.Store(false)
mem.proxyAppConn.FlushAsync()
}

Expand Down
Loading