Status: accepted Date: 2026-10-05 Deciders: GoBridge core Amended by: 0021 (a recovery that fails after its drain and a pre-decode reject are contained in the session instead of latching it closed) Relates to: 0004 (the process restart stays the backstop for every failure a rebuild must not answer), 0018 (a rebuild is a serialized in-place reload of one reload unit)
A session manager that ended with session.ErrSessionUnrecoverable made the
runtime terminal: the process exited and the orchestrator started a new one.
That is the right answer when work of the old session may still run. Most of
the time, though, only one session had failed, and every other session and
route in the process stopped with it.
These MQTT faults end that way. Each one latches the paho session closed, and
each one reaches the supervisor as ErrSessionUnrecoverable wrapping
shared.ErrTransportClosedPermanently:
sessions[].options.session.reconcile_timeout. When route work still holds
deliveries at that bound, the session fails closed.Since ADR 0021, fault 3 no longer latches the session closed; fault 2 does only for a failed drain, a failure before it, or a step that fails closed outside a recovery too.
Any other path that latches the marker ends the same way, for example the pinned replay of a removed filter on a runtime with no dead-letter store.
A single-use exclusive session that wins its lease back after an ordinary
step-down ends the same way: Start after Close returns the permanent marker
(Scenario 8).
The paho session is single-use, so the failed session can never start again. A fresh session can: the builder makes one from the running configuration, and ADR 0018 already replaces a reload unit inside a running runtime.
A session that fails in a way a fresh session clears is rebuilt in place. The composition root rebuilds the one reload unit that holds the session; the rest of the runtime keeps running.
runtime.WithSessionUnrecoverableHandler(h) installs a handler
func(sessionID string, cause error) bool. bridge.WithSessionUnrecoverableHandler
forwards it to the runtime a full build makes. A part built for an in-place
reload needs none: its sessions run under the host runtime’s supervisor.shared.ErrTransportClosedPermanently and does not carry
session.ErrProcessRestartRequired.true means the root took the rebuild. The supervisor counts
SessionRebuilds (tagged session_id) and ends without making the runtime
terminal;false makes the runtime terminal, as before;(*runtime.Runtime).SessionRebuildPending reads it. A fault recorded
during the backoff, and one that needs a process restart, is never pending.session:<id> in
ComponentErrors) keeps the session not ready. Deep health reports it
ready: false with service_level: none, and readiness does not excuse it
as a deferred-connect standby, even when the session waits for its lease
before it connects. Once a rebuild retires the unit, deep health lists
neither the session nor the unit’s routes until the fresh copy is added, as
for any unit an in-place reload replaces; the unit attaches no HTTP
endpoint, so no request the instance takes reaches it. The fresh session
reads not ready until it connects.bridge.Supervisor (cmd/gobridge) and the AWS runtime’s bootstrap.App
install a handler on every runtime they build. The handler:
bridge.PlanSessionRebuild: an in-place reload of the
running configuration onto itself that retires the reload unit holding the
session and adds a freshly built copy. It returns false when no unit holds
the session or the unit may attach an HTTP endpoint (see ADR 0018). While a
reload holds the root’s apply lock, the handler takes the report without
planning and step 3 decides: that reload may run a session the configuration
it publishes last does not hold yet;SessionRebuildPending), and plans the rebuild
again against the configuration the lock now guards. When the runtime has
changed or the report is no longer pending, a reload or a stop got there
first, and it does nothing. So a report that waited for the lock rebuilds
neither a session a reload put in its place, before that session’s own
backoff ends, nor a session whose fault needs a process restart. The
Supervisor also does nothing once it shuts down; the App does nothing once
its configuration is withdrawn, it is wedged, or it shuts down;(*bridge.InPlaceReload).Apply. The plan is always
serialized: the old unit is fully retired — its route work stopped, its
sessions closed — before the copy is built and connects, so the old and the
new session never hold the broker identity at the same time.Every other unit keeps running untouched. A rebuild is not a reload: the applied
configuration, the registry and the API keys stay as they are, and it records
no reload metrics, emits no SwapEvent and starts no convergence watch. The
root logs its outcome with the retired and added routes and sessions.
session.ErrProcessRestartRequired marks an ErrSessionUnrecoverable that a
rebuild inside the process must not answer, because work of the old session may
still be parked or running, or because the process must not compete for the
lease again. The sites that wrap it are:
Reconcile that ignored its context past its ceiling;broker_health_step_down): the process must not compete for the lease
again;The marker says “restart”, not “rebuildable”, on purpose. errors.Is finds a
marker anywhere in the chain, so a positive “rebuildable” marker would survive
a restart-required site that wraps an already-marked error, and that error
would still read as rebuildable. With the negative marker, a wrap by a
restart-required site always reads as restart-required. The cost is the other
direction: a new site that forgets the marker reads as rebuildable. Review
enforces it: every site that returns ErrSessionUnrecoverable while old work
may be parked or running, while a close is incomplete, or when the process must
not compete for the lease again MUST wrap ErrProcessRestartRequired.
The rebuild changes no lease rule. A session manager whose reconcile returns
the permanent marker, as when ingress did not quiesce (fault 1), keeps its
lease, since route work may still hold deliveries, and the retire leaves it
held. Any other failure releases the lease once the source closed. A failure of
the running session first waits the settlement grace a step-down waits
(StepDownGrace), and a send that completes after it is the duplicate a
step-down accepts. The rebuilt session competes for the lease only after the
old unit is retired, so its route work has stopped. A failure whose source
close did not complete keeps the lease and carries ErrProcessRestartRequired.
The runtime still goes terminal, and the process restart (ADR 0004) stays the backstop, when:
runtime.Runtime an embedder builds without
WithSessionUnrecoverableHandler;ErrProcessRestartRequired;shared.ErrTransportClosedPermanently, for
example an exclusive activation that overran its deadline after its source
closed;wedged). The retire lets the unit’s
in-flight deliveries settle for up to 25 s before it cancels them, all inside
the drain timeout. A delivery still held at that point wedges the rebuild when
its sender ignores the cancel, or when the drain timeout leaves the route no
time to stop after the cancel: a drain_timeout of 25 s or less.A rebuild that tears (torn) is handled like a torn reload: the root stops the
runtime and builds the running configuration afresh, and wedges when that fails.
SessionRebuilds counts the rebuilds a handler took. The failed session reads
not ready until a rebuild or retire clears its fault.SessionRebuilds rate and on the session’s readiness. Since ADR 0021 a
malformed packet drops only the connection, so this risk covers it only for a
lease-managed session whose broker sends the packet again on every resume,
where the reject fails the reconcile after the reconnect.runtime.Runtime directly keeps the old behaviour
unless it installs a handler.The transport side of faults 2 and 3 is unchanged. A settlement recovery that fails after a successful drain, and an ingress-poison rejection, still latch the session closed, and only the rebuild above brings the session back. Letting the MQTT transport recover from those without closing the session is a separate decision, recorded in its own ADR when it lands. ADR 0021 has since made that decision and amends this paragraph, as the Context note says.