From 268652ca632f8247a12cdd9a22565398108bafd4 Mon Sep 17 00:00:00 2001 From: tnasu Date: Thu, 13 Jul 2023 18:13:52 +0900 Subject: [PATCH] mempool: ensure async requests are flushed to the server (#9010) 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 --- abci/client/grpc_client.go | 1 + mempool/v1/mempool.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/abci/client/grpc_client.go b/abci/client/grpc_client.go index fca631967..d6f760196 100644 --- a/abci/client/grpc_client.go +++ b/abci/client/grpc_client.go @@ -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() diff --git a/mempool/v1/mempool.go b/mempool/v1/mempool.go index c2f56c261..96925e219 100644 --- a/mempool/v1/mempool.go +++ b/mempool/v1/mempool.go @@ -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, @@ -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()