go-ethereum/core/state/snapshot
ozpool 963d78dfcc core/state/snapshot: make diskLayer.stopGeneration idempotent
Fixes the deadlock noted by the "TODO this function will hang if it's
called twice" markers in Tree.Disable and Tree.Rebuild. Both paths walk
every layer in the tree and unconditionally invoke stopGeneration on
each disk layer, so a layer reachable through both must tolerate a
second call.

The previous implementation sent on the unbuffered genAbort channel
whenever genMarker was non-nil. After the first abort handshake the
generator goroutine exits, but genMarker is only cleared on the
successful-completion path (generate.go), not on the aborted-mid-flight
path. A second stopGeneration therefore saw generating=true, sent on
genAbort with no receiver, and blocked forever.

Wrap the abort handshake in a sync.Once on the disk layer. The first
call drives the handshake exactly as before; subsequent calls are
no-ops. Remove both TODO comments now that the contract is honoured.

Adds TestStopGenerationIdempotent: stands in a mock generator goroutine
that consumes a single abort, calls stopGeneration twice, and fails
with an explicit message at a 5s deadline rather than hanging until
the test runner's outer timeout.

Fixes #33233.
2026-05-13 13:01:45 +05:30
..
context.go all: get rid of custom MaxUint64 and MaxUint64 (#30636) 2024-10-20 14:41:51 +03:00
conversion.go all: improve ETA calculation across all progress indicators (#32521) 2025-09-01 13:47:02 +08:00
difflayer.go core/state/snapshot: fix storageList memory accounting (#33505) 2025-12-31 09:40:43 +08:00
difflayer_test.go core/state/snapshot: fix storageList memory accounting (#33505) 2025-12-31 09:40:43 +08:00
disklayer.go core/state/snapshot: make diskLayer.stopGeneration idempotent 2026-05-13 13:01:45 +05:30
disklayer_test.go core/state/snapshot: make diskLayer.stopGeneration idempotent 2026-05-13 13:01:45 +05:30
generate.go core, trie, triedb: minor changes from snapshot integration (#30599) 2024-10-18 17:06:31 +02:00
generate_test.go crypto/keccak: vendor in golang.org/x/crypto/sha3 (#33323) 2026-02-03 14:55:27 -07:00
holdable_iterator.go all: update license headers and AUTHORS from git history (#24947) 2022-05-24 20:39:40 +02:00
holdable_iterator_test.go all: update license headers and AUTHORS from git history (#24947) 2022-05-24 20:39:40 +02:00
iterator.go core, triedb: remove destruct flag in state snapshot (#30752) 2024-11-22 16:55:43 +08:00
iterator_binary.go core, triedb: remove destruct flag in state snapshot (#30752) 2024-11-22 16:55:43 +08:00
iterator_fast.go all: use cmp.Compare (#30958) 2025-01-02 14:06:47 +01:00
iterator_test.go core/state/snapshot: fix condition in iterator traversal test (#34638) 2026-05-01 20:22:48 +02:00
journal.go all: replace fmt.Errorf with errors.New (#32286) 2025-07-28 10:13:18 +02:00
metrics.go all: fix spelling mistakes (#25961) 2022-10-11 09:37:00 +02:00
snapshot.go core/state/snapshot: make diskLayer.stopGeneration idempotent 2026-05-13 13:01:45 +05:30
snapshot_test.go core, triedb: remove destruct flag in state snapshot (#30752) 2024-11-22 16:55:43 +08:00
utils.go core, triedb: remove destruct flag in state snapshot (#30752) 2024-11-22 16:55:43 +08:00