Skip to content

fix(lane): bring a lane fully back when its RPM returns after an outage - #56

Merged
4 commits merged into
ORNL:mainfrom
mjd948:fix/lane-rpm-recovery
Nov 24, 2026
Merged

4 commits merged into
ORNL:mainfrom
mjd948:fix/lane-rpm-recovery

Conversation

@mjd948

@mjd948 mjd948 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Problem

LaneSystem configures every RPM driver (Rapiscan, Aspect, RS-350) with
reconnectAttempts = 10, 10 s apart. After that, RobustConnection throws "Maximum number of
connection attempts reached", and the RPM module stays STOPPED with an error, or LOADED with an
error if the device was down at boot. Nothing retries, so any outage longer than about two minutes
(a switch reboot, a cable pull) takes the lane's radiation data down until someone restarts the
module by hand. Defect issue #51.

Reproduced on a 3.11 Compose stack with a Rapiscan simulator down for 4 minutes: the RPM module
stayed in ERROR for good.

Fix (four commits)

  1. RpmRecoverySupervisor, one per lane while the lane is started.

    • Every 15 s it checks the RPM member. It acts only on a member that is auto-start, carries an
      error, and is LOADED or STOPPED: it re-runs init (if needed) and start.
    • Failed rounds back off 30 s, then 60 s, 2 min and 5 min.
    • A member an operator stopped on purpose has no error and is left alone.
  2. Readiness. Each recovery attempt holds the member in STARTING for the driver's connection
    loop (about 100 s), and ApplicationReadiness read that as a start still in flight. So one
    unreachable detector kept the ready marker down and the container unhealthy, and oscar.sh start/restart failed. The supervisor now reports when it is recovering
    (IAutoStartDispatchStatus.isMemberUnderRecovery). Readiness treats such a member as settled
    once the lane's own auto-start dispatch is complete.

  3. Start the RS-350 occupancy process when its detector comes up late. Found in the field
    today, and present in ORNL's code path too:

    • SensorSystem gives each auto-start member 10 s to initialize. The RS-350 occupancy process
      initializes only once its detector is STARTED, so a detector that is down at boot leaves it
      un-started.
    • When the detector comes up later (this supervisor, or an operator restarting the RPM),
      LaneSystem's STARTED handler re-runs occupancyProducer.init(). That also resets a running
      process to INITIALIZED, because AbstractModule.canInit() always proceeds, and nothing
      starts it.
    • Result: the lane records no occupancies and readiness stays withdrawn. On a 24/7 node this
      lasted 100 minutes, until a restart.
    • OccupancyProcessStarter now starts the process on the lane executor, only after the lane's
      auto-start pass, when the process is auto-start and still INITIALIZED.
  4. Re-attach the lane's WebID, OCR and EML helpers when a detector comes up late.

    • LaneSystem creates these helpers in afterStart, bound to the occupancy producer.
      WebIdHelper waits 5 s and OcrHelper 10 s for it to reach STARTED, and both give up at
      once when it is in error, because waitForState rethrows the module's error. That is where a
      detector offline at boot leaves its RPM.
    • Nothing retried. After the detector came back, an RS-350 lane ran without WebID analysis
      ("Failed to create WebId/Occupancy subscription"), and a portal lane without vehicle OCR
      ("OCR inactive on lane"), until the next node restart.
    • Each helper now reports whether it attached, or is still waiting. When the occupancy producer
      reaches STARTED after the lane's auto-start pass, the lane re-creates only the helpers that
      gave up, on the lane executor.
    • EML is re-attached on portal lanes only. On RS-350 lanes its producer has no UID when the
      helper is created, so it never subscribes there today. Whether it should is your call.

Compatibility

  • No config changes.
  • Behaviour change: an auto-start RPM that failed is retried indefinitely with backoff. An
    operator-stopped RPM is untouched.

Tests

  • RpmRecoverySupervisorTest (7), ApplicationReadinessTest (new case) and
    OccupancyProcessStarterTest (10). Commit 4 has no unit test of its own: the helpers need a
    running hub. It was verified on a Compose stack instead (see below).
  • Run on the 3.11.13 tree (ORNL/oscar checkout with this branch overlaid): node tools/validate-release-metadata.js passes, and :sensorhub-system-lane:test with
    :sensorhub-service-oscar:test passes 341, 18 skipped, with 0 failures.

Field evidence

  • 3.11 Compose stack: Rapiscan data was back 19 s after a 4-minute simulator outage ended. Booting
    with the RPM unreachable for 5 minutes left the node healthy, and the RPM started 3 s after the
    simulator came up.
  • 24/7 node: an RS-350 that was unreachable at boot was recovered by the supervisor after 50
    minutes. Commit 3 is the fix for what that run showed: the occupancy process was never started.
    Commit 3 was then checked on a Compose stack with the RS-350 simulator off at boot and back
    later. Without it, the occupancy process stayed INITIALIZED and readiness stayed down; with it,
    the process started 1 ms after its init and readiness came back. It has been running on the
    24/7 node since.
  • Commit 4, on a Compose stack with the RS-350 and one Rapiscan simulator off at boot and back
    later. Without it, the RS-350 lane logged "Failed to create WebId/Occupancy subscription", the
    portal lane logged "OCR inactive", and neither recovered. With it, both re-attached
    (Re-attached WebID …, Re-attached vehicle OCR …) within milliseconds of their detectors
    starting. A normal boot re-attaches nothing. Running on the 24/7 node since then.

Known, not addressed here

When an RS-350's RPM restarts while its occupancy process is running, LaneSystem re-runs init()
on that process. Rs350OccupancyProcessModule.initChain() then builds a new chain whose
Rs350OutputToOccupancy subscribes again, and the old chain's subscriptions are cancelled only in
dispose(). That may duplicate subscriptions. This is suspected from reading the code and has not
been reproduced. Commit 3 makes sure the process is started again, but not that the old chain is
disposed.

Merge note

#57 (Mobile Detector System) touches two spots that this PR also changes in
LaneSystem.afterStart: the lines next to startRpmRecovery(), and the old WebID-helper line,
where #57 adds a null check that commit 4 already contains. Whichever of the two merges second
needs a small rebase, which we'll do.

🤖 Generated with Claude Code

mjd948 and others added 4 commits November 24, 2026 21:22
On the 3.11 scratch stack a Rapiscan simulator that was down for 4 minutes
never came back: the lane configures every RPM driver with 10 retries 10 s
apart, RobustConnection then throws "Maximum number of connection attempts
reached", and the module stays STOPPED with an error (or LOADED with an
error when the device was down at boot). Nothing retried from there, so any
outage longer than about two minutes (switch reboot, cable pull) took the
lane's radiation data down until someone restarted the module by hand.

RpmRecoverySupervisor runs per lane while the lane is started. Every 15 s
it looks at the RPM member and, only if it is auto-start, carries an error,
and sits in LOADED or STOPPED, re-runs init (if needed) and start. Failed
rounds back off 30 s / 60 s / 2 min / 5 min. A member an operator stopped
on purpose has no error and is left alone. The lane's existing STARTED
handler re-wires occupancy once the member is up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The RPM recovery supervisor restarts a failed RPM member, and each attempt
holds it in STARTING for the driver's whole connection loop (about 100 s).
Application readiness reads a nested STARTING member as a start still in
flight, so one detector that stayed unreachable kept the ready marker down
and the whole node unhealthy; oscar.sh start/restart then failed.

The supervisor now reports when it is recovering, LaneSystem exposes that
through IAutoStartDispatchStatus.isMemberUnderRecovery, and readiness treats
such a member as settled once the lane's own auto-start dispatch is complete.

Found at the live cutover: the site's RS-350 simulator was down.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SensorSystem starts a lane's auto-start members once, right after the lane starts, and waits at
most 10 s for each to initialize. The RS-350 occupancy process (and the Kromek D5 one on mobile
detector lanes) is initialized only when its detector reaches STARTED, so a detector that is
offline at boot leaves it un-started ("Cannot start subsystem ... - Occupancy"). When the
detector comes up later (RpmRecoverySupervisor or an operator restart), LaneSystem initializes
the process again, which also resets a running process to INITIALIZED, but nothing starts it.
The lane then records no occupancies for that detector and application readiness stays
withdrawn, so the container reports unhealthy.

Seen in the field: a walker lane booted while its RS-350 was unreachable; 50 min later the
supervisor recovered the detector, the process stayed INITIALIZED for 100 min until a restart,
and the node was unhealthy for the whole time.

After that init, OccupancyProcessStarter now starts the process on the lane's executor, but only
once the lane's own auto-start pass is over (autoStartDispatchComplete), the process is
auto-start, and it is still INITIALIZED when the task runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tarts late

LaneSystem creates its occupancy helpers in afterStart, each bound to the occupancy producer:
WebIdHelper waits 5 s for it to reach STARTED, OcrHelper 10 s, and both give up at once when it
is in error (AbstractModule.waitForState rethrows the module's error), which is where a detector
that was offline at boot leaves an RPM. EmlAutoAdjudicationHelper silently skips subscribing
without a producer UID. None of them retried, so after RpmRecoverySupervisor (or an operator)
brought the detector back, an RS-350 lane ran without WebID analysis ("Failed to create
WebId/Occupancy subscription") and a portal lane without vehicle OCR ("OCR inactive on lane")
until the next node restart.

Each helper now reports whether it is attached (or still waiting), the helper construction moved
out of afterStart into attach* methods guarded by one lock, and when the occupancy producer
reaches STARTED after the lane's auto-start pass, LaneSystem re-creates only the helpers that
gave up, on the lane executor. EML is re-attached on portal lanes only: on RS-350/D5 lanes its
producer (the occupancy process) has no UID when the helper is created, so it never subscribes
there today, and re-attaching would newly enable it. A normal boot is unchanged: helpers that attached or are still
waiting are left alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tyronechrisharris tyronechrisharris closed this pull request by merging all changes into ORNL:main in 7a7324a Nov 24, 2026
@tyronechrisharris

Copy link
Copy Markdown
Collaborator

Merged into main (7a7324ae) via ORNL/osh-oakridge-modules#58 for OSCAR v3.11.14.

Architectural Review & Unification with #48 (c0c509ab)

RpmRecoverySupervisor, OccupancyProcessStarter, ApplicationReadiness, and the LaneSystem helper re-attach hooks (AdjudicationControl, OcrHelper, WebIdHelper, EmlAutoAdjudicationHelper) cleanly solve late detector recovery. Before merging, we unified #56 with @kalynstricklin's ORNL/osh-oakridge-modules#48 to close two subtle RS-350 async lifecycle races:

  1. initAsync = true Support in OccupancyProcessStarter: Because Rs350OccupancyProcessModule sets initAsync = true in its constructor, init() returns in ModuleState.INITIALIZING before transitioning to INITIALIZED on its worker thread. OccupancyProcessStarter.startIfStranded(...) now accepts INITIALIZING as well as INITIALIZED and calls waitForState(ModuleState.INITIALIZED, 10_000) on LaneSystem.threadPool (never blocking the OSH EventBus thread) before invoking start() (verified by OccupancyProcessStarterTest.waitsForAsyncInitializationBeforeStarting).
  2. Early-Started RS-350 Boot Race & Code 9998 EML Re-Attach (LaneSystem): LaneSystem.afterStart() now triggers occupancyProducer.init() + OccupancyProcessStarter.startIfStranded(...) if RS350Sensor had already reached STARTED before afterStart() subscribed, and emlReattachExpected() checks occupancyProducer.getUniqueIdentifier() != null so RS-350 extended-occupancy Code 9998 auto-adjudication attaches once the occupancy process starts.

mjd948 added a commit to mjd948/osh-oakridge-modules that referenced this pull request Nov 25, 2026
ORNL squash-merged our session, RS-350, lane-recovery and WebID fixes
(ORNL#54, ORNL#55, ORNL#56, ORNL#60) plus their own follow-ups (ORNL#61), so their side was
taken in every conflict except two:

- LaneSystem keeps our Mobile Detector design (the occupancy process
  member is reused across restarts and covers D5 walkers); ORNL's
  "detector already started" start-up is kept for a newly created
  process, for RS-350 and D5 alike. EML re-attach follows ORNL.
- Rs350OccupancyProcessModule takes ORNL's version: its event-bus
  restart handler (where our orphan guard lived) is gone upstream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tyronechrisharris added a commit that referenced this pull request Nov 26, 2026
feat(v3.12.0): Mobile Detector System, 26-output PARQUET_PRIMARY allowlist, per-stream OCR/adjudication watermarks, screenshots #56-#57 & 3.12.0 metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants