From af579f97fbad299806bf342239649e193cd55698 Mon Sep 17 00:00:00 2001 From: lupin012 <58134934+lupin012@users.noreply.github.com.> Date: Sun, 6 Sep 2026 15:22:25 +0200 Subject: [PATCH] common/concurrent, db/snapshotsync: drop three review leftovers from #23812 Post-merge review cuts on the FrozenBlocks/CachedValue code merged in #23812, no behavior change. - FrozenBlocksObserved waits with time.After instead of NewTimer plus a deferred Stop: since go 1.23 an unreferenced timer is collected on its own, and the one-shot select form is what kvcache and kv_mdbx already use. - The publish docstring claimed that closing done before clearing running keeps a waiter from starting a pass of its own. Both writes happen under c.mu and claim takes the same mutex, so no caller can observe that order. - run returns bare, the named results are already assigned on the line above. --- common/concurrent/cached_value.go | 6 ++---- db/snapshotsync/freezeblocks/block_reader.go | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/common/concurrent/cached_value.go b/common/concurrent/cached_value.go index 18e1dbcbc83..5ed84be8ef9 100644 --- a/common/concurrent/cached_value.go +++ b/common/concurrent/cached_value.go @@ -123,12 +123,10 @@ func (c *CachedValue[T]) run(r *run[T], produce func() (T, bool, error)) (value }() value, store, err = produce() - return value, err + return } -// publish records the attempt, stores what is worth keeping, and ends the pass. Closing -// done before clearing running keeps a caller from starting a pass of its own while this -// one is still published as in flight. +// publish records the attempt, stores what is worth keeping, and ends the pass. func (c *CachedValue[T]) publish(r *run[T], value T, store bool, err error) { c.mu.Lock() defer c.mu.Unlock() diff --git a/db/snapshotsync/freezeblocks/block_reader.go b/db/snapshotsync/freezeblocks/block_reader.go index 9d4786b8516..1f9f503359f 100644 --- a/db/snapshotsync/freezeblocks/block_reader.go +++ b/db/snapshotsync/freezeblocks/block_reader.go @@ -172,11 +172,9 @@ func (r *RemoteBlockReader) FrozenBlocksObserved() (uint64, bool) { if observed { return value, true } - timeout := time.NewTimer(r.frozenBlocksTimeout) - defer timeout.Stop() select { case <-refreshed: - case <-timeout.C: + case <-time.After(r.frozenBlocksTimeout): } value, observed, _ = r.frozenBlocks.Load() return value, observed