Skip to content

prefetcher: recover panics in worker and sendPlan goroutines

2020293
Select commit
Loading
Failed to load commit list.
Open

prefetcher: builder-phase prefetch + streaming worker pool #2192

prefetcher: recover panics in worker and sendPlan goroutines
2020293
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Apr 20, 2026 in 18m 4s

Code review found 1 important issue

Found 5 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important miner/worker.go:2371-2374 Goroutine leak: runPrefetcher panic leaves PrefetchStream workers permanently blocked
🟡 Nit miner/worker.go:2540-2555 Double-prefetch race: plan tx and overflow tx can overlap within 2ms batch window

Annotations

Check failure on line 2374 in miner/worker.go

See this annotation in the file changed.

@claude claude / Claude Code Review

Goroutine leak: runPrefetcher panic leaves PrefetchStream workers permanently blocked

In runPrefetcher, the shutdown block (evmAbort.Store(true) / close(txsCh) / <-streamDone) is sequential code at the end of the function, not deferred. If runIdleTxProvider or runBuilderTxProvider panics, Go unwinds into the recover() wrapper in commitWork's goroutine launcher, skipping cleanup entirely — txsCh is never closed, permanently blocking all PrefetchStream worker goroutines waiting on 'for tx := range s.txsCh'. The hardKill check inside the range body cannot unblock workers stuck on an

Check warning on line 2555 in miner/worker.go

See this annotation in the file changed.

@claude claude / Claude Code Review

Double-prefetch race: plan tx and overflow tx can overlap within 2ms batch window

In runBuilderTxProvider, a plan tx forwarded to txsCh can be forwarded a second time by scanOverflow within the next 2ms batch window if the worker executing it has not yet called onSuccess (which writes to prefetchedHashes). This causes two workers to execute EVM on the same tx concurrently on independent throwaway state copies, wasting worker capacity. Fix: maintain a separate in-flight set populated when a tx is sent to txsCh (before EVM completion) and exclude in-flight hashes from scanOverf