bug6241: detach retype-and-store callback onto its own thread

The Runnable passed to runWhenWindEstimationInstalled(...) fires
synchronously on whichever thread first invokes setWindEstimation with
a non-null argument. That thread is typically a shared
background-executor thread (the same pool used by SmartFutureCache and
the wind estimator's GraphRecalculationTask). Running waitUntilDone,
recalculate(...), and get(waitForLatest=true) on that thread makes the
callback block waiting for tasks that need the same pool to progress,
which starves the pool -- fatal with pool size 1, and observed as
timeout retries on saturated pools in local runs.

Detach the callback body onto a dedicated Thread so the setWindEstimation
caller returns immediately and the shared pool stays free to service the
tasks the retype-and-store step is waiting on.
This commit is contained in:
Axel Uhl committed 2026-07-26 22:40:05 +02:00
1 parent d3795248ea
commit 8ce464986b
1 file changed
+10 -2
@@ -162,8 +162,16 @@ public class ManeuverCacheDelegate implements SerializableManeuverCache {
// fires synchronously here if the estimator was installed while we were computing;
// otherwise it registers a callback that fires once setWindEstimation is called with
// a non-null argument, and cancels silently if the race is removed before that
// happens. See bug6241 for the rationale.
race.runWhenWindEstimationInstalled(this::retypeAndStoreAfterWindEstimationSettled);
// happens. Because the setWindEstimation call typically happens on a shared
// background-executor thread and the follow-up work (waitUntilDone, recalculate,
// get(waitForLatest=true)) then blocks waiting for other tasks on the *same* shared
// pool, running it on the setWindEstimation caller's thread risks starving the pool
// (fatal with pool size 1). Detach onto a dedicated thread so the caller of
// setWindEstimation returns immediately. See bug6241 for the rationale.
race.runWhenWindEstimationInstalled(() ->
new Thread(this::retypeAndStoreAfterWindEstimationSettled,
"Retyping and storing maneuvers after wind estimation for "+race.getName())
.start());
}
}