mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-02 01:00:46 +00:00
Two related fixes for the permanent hang where a request thread held the raceTrackersByRegatta write lock while parked in Object.wait(), timing out all subsequent requests to the service. TrackedRaceImpl.waitForAllRaceLogsAttached(): the wait guard re-evaluates the live attached-race-log count inside the synchronized(latchForRaceLogs) block instead of a stale local captured before entering the monitor. The stale local could never change, so a notifyAll() that fired between the initial read and entering wait() was lost, parking the thread forever (classic lost-wakeup). RacingEventServiceImpl.addRace(...): split the register-or-notify handshake so that only *claiming* (removing) the callbacks for the new tracker happens under the raceTrackersByRegatta write lock, atomically with publishing the tracker; the callbacks are then *invoked* after the lock is released. A callback may block during tracker startup (waiting for race logs to attach), and previously that wait ran while holding the global write lock, turning a single stalled tracker into a service-wide outage. The read-locked find-or-enqueue in getRaceTrackerByRegattaAndRaceIdentifier(...) still races atomically against the claim, so no callback can be lost. Assisted-By: Claude Opus 4.8