From be29110d7521e14654d156698072b5dc4e3828a8 Mon Sep 17 00:00:00 2001 From: "Luis Guzman (AppDevForAll)" Date: Wed, 26 Aug 2026 01:14:55 -0600 Subject: [PATCH] ADFA-5280 fix(server): post-batch ensure decides on fresh liveness, not the stale cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ServerController.startEnvironment() fed EnvironmentEnsure.decide() the cached ServerStateRepository.alive, which still reads TRUE right after a module batch's pdsm stop (the 3s poll hasn't caught up), so decide() returned NOOP_HEALTHY and the box was never relaunched — Home "Couldn't start" until a manual Retry. Read liveness from a live probe (RestReadiness.apiReady()) instead: a just-stopped server reads down at once -> KILL_AND_RELAUNCH; a healthy env still reads up -> NOOP_HEALTHY, so no double-boot. The decision already runs off the main thread. --- .../main/java/org/iiab/controller/ServerController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/controller/app/src/main/java/org/iiab/controller/ServerController.java b/controller/app/src/main/java/org/iiab/controller/ServerController.java index 6812bce94..074203a2f 100644 --- a/controller/app/src/main/java/org/iiab/controller/ServerController.java +++ b/controller/app/src/main/java/org/iiab/controller/ServerController.java @@ -274,7 +274,13 @@ public void startEnvironment() { AppExecutors.get().io().execute(() -> { boolean envAlive = org.iiab.controller.env.EnvironmentProcess.isRunning(activity); long ageMs = envAlive ? org.iiab.controller.env.EnvironmentProcess.environmentAgeMs(activity) : -1L; - boolean servicesAlive = ServerStateRepository.get().current().alive; + // ADFA-5280: decide on FRESH liveness, not the cached ServerStateRepository.alive. + // Right after a module batch's `pdsm stop`, the cache still reads TRUE until the 3s poll + // catches up, so decide() returned NOOP_HEALTHY and the box was never relaunched (Home + // "Couldn't start" until a manual Retry). A live probe reads a just-stopped server as down + // at once (connection refused); a genuinely-healthy env still answers true -> NOOP_HEALTHY, + // so this never double-boots. Safe here: this block already runs off the main thread. + boolean servicesAlive = org.iiab.controller.redesign.RestReadiness.apiReady(); org.iiab.controller.env.domain.EnvironmentEnsure.Action action = org.iiab.controller.env.domain.EnvironmentEnsure.decide( envAlive, ageMs, servicesAlive, BOOT_GRACE_MS);