From 10a50ef45235eb70f5e7a593f5aa7dabb7ab7aca Mon Sep 17 00:00:00 2001 From: Slyghtning Date: Mon, 11 May 2026 16:58:45 +0200 Subject: [PATCH] instantout/reservation: lock initial currentHeight write in Run Run wrote m.currentHeight = height without holding the lock, while later writes (newBlockChan case) and reads in RequestReservationFromServer take m.Lock. Daemon startup serializes 'wait for initChan' before serving RPC, so in practice the race window is short, but the race detector flags it -- and on the nautilus side a similar pattern is the most plausible cause of the unit-race CI failure on the buy-reservations head commit. Symmetric fix here keeps the synchronisation rule uniform. --- instantout/reservation/manager.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/instantout/reservation/manager.go b/instantout/reservation/manager.go index fe2952b8..037e33d3 100644 --- a/instantout/reservation/manager.go +++ b/instantout/reservation/manager.go @@ -92,7 +92,13 @@ func (m *Manager) Run(ctx context.Context, height int32, runCtx, cancel := context.WithCancel(ctx) defer cancel() + // Take the lock for the initial write so the race detector sees a + // consistent synchronisation rule (later writes in the new-block + // case already lock; concurrent reads in RequestReservationFromServer + // already lock). + m.Lock() m.currentHeight = height + m.Unlock() err := m.RecoverReservations(runCtx) if err != nil {