From a1626f2e65c9eb15712caab611e77ba1ad038f87 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Fri, 17 Jan 2025 19:04:37 +0700 Subject: [PATCH] txpool: race in logging (#13478) closing https://github.com/erigontech/erigon/issues/13477 --- txnprovider/txpool/pool.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/txnprovider/txpool/pool.go b/txnprovider/txpool/pool.go index 36180831df0..b0546d5c2c2 100644 --- a/txnprovider/txpool/pool.go +++ b/txnprovider/txpool/pool.go @@ -309,10 +309,6 @@ func (p *TxPool) OnNewBlock(ctx context.Context, stateChanges *remote.StateChang baseFee := stateChanges.PendingBlockBaseFee available := len(p.pending.best.ms) - defer func() { - p.logger.Debug("[txpool] New block", "block", block, "unwound", len(unwindTxns.Txns), "mined", len(minedTxns.Txns), "baseFee", baseFee, "pending-pre", available, "pending", p.pending.Len(), "baseFee", p.baseFee.Len(), "queued", p.queued.Len(), "err", err) - }() - if err = minedTxns.Valid(); err != nil { return err } @@ -332,6 +328,10 @@ func (p *TxPool) OnNewBlock(ctx context.Context, stateChanges *remote.StateChang p.lock.Unlock() }() + defer func() { + p.logger.Debug("[txpool] New block", "block", block, "unwound", len(unwindTxns.Txns), "mined", len(minedTxns.Txns), "baseFee", baseFee, "pending-pre", available, "pending", p.pending.Len(), "baseFee", p.baseFee.Len(), "queued", p.queued.Len(), "err", err) + }() + if assert.Enable { if _, err := kvcache.AssertCheckValues(ctx, coreTx, cache); err != nil { p.logger.Error("AssertCheckValues", "err", err, "stack", stack.Trace().String())