From 5759b58a72d0f210d6c1ee187b21fbd6a0d83873 Mon Sep 17 00:00:00 2001 From: Pavel Zbitskiy Date: Fri, 20 Sep 2024 17:10:15 -0400 Subject: [PATCH] fix cached id data race --- data/txHandler.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/data/txHandler.go b/data/txHandler.go index f7746db4cb..8f0ebebd68 100644 --- a/data/txHandler.go +++ b/data/txHandler.go @@ -342,6 +342,10 @@ func (handler *TxHandler) backlogWorker() { logging.Base().Warnf("Failed to release capacity to ElasticRateLimiter: %v", err) } } + // precompute transaction IDs + for i := range wi.unverifiedTxGroup { + wi.unverifiedTxGroup[i].CacheID() + } if handler.checkAlreadyCommitted(wi) { transactionMessagesAlreadyCommitted.Inc(nil) if wi.capguard != nil { @@ -531,11 +535,6 @@ func (handler *TxHandler) postProcessCheckedTxn(wi *txBacklogMsg) { // at this point, we've verified the transaction, so we can safely treat the transaction as a verified transaction. verifiedTxGroup := wi.unverifiedTxGroup - // precompute transaction IDs - for i := range verifiedTxGroup { - verifiedTxGroup[i].CacheID() - } - // save the transaction, if it has high enough fee and not already in the cache err := handler.txPool.Remember(verifiedTxGroup) if err != nil {