mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-08 20:11:21 +00:00
e3: worker stuck on exit (#6826)
This commit is contained in:
parent
0ebac009e7
commit
910ea64c3e
@ -99,7 +99,11 @@ func (rw *Worker) ResetTx(chainTx kv.Tx) {
|
||||
func (rw *Worker) Run() {
|
||||
for txTask, ok := rw.rs.Schedule(); ok; txTask, ok = rw.rs.Schedule() {
|
||||
rw.RunTxTask(txTask)
|
||||
rw.resultCh <- txTask // Needs to have outside of the lock
|
||||
select {
|
||||
case rw.resultCh <- txTask: // Needs to have outside of the lock
|
||||
case <-rw.ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,6 +314,7 @@ func (cr EpochReader) FindBeforeOrEqualNumber(number uint64) (blockNum uint64, b
|
||||
}
|
||||
|
||||
func NewWorkersPool(lock sync.Locker, ctx context.Context, background bool, chainDb kv.RoDB, rs *state.StateV3, blockReader services.FullBlockReader, chainConfig *chain.Config, logger log.Logger, genesis *core.Genesis, engine consensus.Engine, workerCount int) (reconWorkers []*Worker, applyWorker *Worker, resultCh chan *exec22.TxTask, clear func()) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
var wg sync.WaitGroup
|
||||
queueSize := workerCount * 2
|
||||
reconWorkers = make([]*Worker, workerCount)
|
||||
@ -319,11 +324,13 @@ func NewWorkersPool(lock sync.Locker, ctx context.Context, background bool, chai
|
||||
}
|
||||
applyWorker = NewWorker(lock, ctx, false, chainDb, rs, blockReader, chainConfig, logger, genesis, resultCh, engine)
|
||||
clear = func() {
|
||||
cancel()
|
||||
wg.Wait()
|
||||
for _, w := range reconWorkers {
|
||||
w.ResetTx(nil)
|
||||
}
|
||||
applyWorker.ResetTx(nil)
|
||||
close(resultCh)
|
||||
}
|
||||
if background {
|
||||
wg.Add(workerCount)
|
||||
|
Loading…
Reference in New Issue
Block a user