Skip to content

Commit

Permalink
mempool: ensure async requests are flushed to the server (#9010)
Browse files Browse the repository at this point in the history
In the v0.34 line, the socket and gRPC clients require explicit flushes to
ensure that the client and server have received an async request.  Add these
calls explicitly where required in the backport of the priority mempool.

In addition, the gRPC client's flush plumbing was not fully hooked up in the
v0.34 line, so this change includes that update as well.

Co-authored: M. J. Fromberger <fromberger@interchain.io>
  • Loading branch information
tnasu committed Jul 13, 2023
1 parent f65a4a7 commit 611c340
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions abci/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ func (cli *grpcClient) finishAsyncCall(req *ocabci.Request, res *ocabci.Response
}

// ----------------------------------------

func (cli *grpcClient) FlushSync() (*types.ResponseFlush, error) {
reqres := cli.FlushAsync(nil)
reqres.Wait()
Expand Down
7 changes: 7 additions & 0 deletions mempool/v1/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ func (txmp *TxMempool) CheckTx(tx types.Tx, cb func(*abci.Response), txInfo memp
// the callback deadlock trying to acquire the same lock. This isn't a
// problem with out-of-process calls, but this has to work for both.
reqRes := txmp.proxyAppConn.CheckTxAsync(abci.RequestCheckTx{Tx: tx})
if err := txmp.proxyAppConn.FlushSync(); err != nil {
return err
}
reqRes.SetCallback(func(res *abci.Response) {
wtx := &WrappedTx{
tx: tx,
Expand Down Expand Up @@ -724,6 +727,10 @@ func (txmp *TxMempool) recheckTransactions() {
Tx: wtx.tx,
Type: abci.CheckTxType_Recheck,
})
if err := txmp.proxyAppConn.FlushSync(); err != nil {
atomic.AddInt64(&txmp.txRecheck, -1)
txmp.logger.Error("mempool: error flushing re-CheckTx", "key", wtx.tx.Key(), "err", err)
}
}

txmp.proxyAppConn.FlushAsync()
Expand Down

0 comments on commit 611c340

Please sign in to comment.