From 6aae186facb64ee2633e4ff9ed70b90d943d3b8c Mon Sep 17 00:00:00 2001 From: hexoscott <70711990+hexoscott@users.noreply.github.com> Date: Thu, 12 Jan 2023 00:59:43 +0000 Subject: [PATCH] wait on error from call to parallelWarmup (#6558) --- eth/stagedsync/stage_hashstate.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/eth/stagedsync/stage_hashstate.go b/eth/stagedsync/stage_hashstate.go index 52b01b358..8d2e7d355 100644 --- a/eth/stagedsync/stage_hashstate.go +++ b/eth/stagedsync/stage_hashstate.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "runtime" + "sync" "time" libcommon "github.com/ledgerwatch/erigon-lib/common" @@ -18,14 +19,15 @@ import ( "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/temporal/historyv2" "github.com/ledgerwatch/erigon-lib/state" + "github.com/ledgerwatch/log/v3" + "golang.org/x/sync/errgroup" + "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/eth/ethconfig/estimate" - "github.com/ledgerwatch/log/v3" - "golang.org/x/sync/errgroup" ) type HashStateCfg struct { @@ -151,17 +153,28 @@ func unwindHashStateStageImpl(logPrefix string, u *UnwindState, s *StageState, t } func PromoteHashedStateCleanly(logPrefix string, tx kv.RwTx, cfg HashStateCfg, ctx context.Context) error { - if err := promotePlainState( + err := promotePlainState( logPrefix, cfg.db, tx, cfg.dirs.Tmp, ctx, - ); err != nil { + ) + if err != nil { + return err + } + + wg := sync.WaitGroup{} + wg.Add(1) + go func() { + err = parallelWarmup(ctx, cfg.db, kv.PlainContractCode, 2) + wg.Done() + }() + wg.Wait() + if err != nil { return err } - go parallelWarmup(ctx, cfg.db, kv.PlainContractCode, 2) return etl.Transform( logPrefix, tx,