gobridge

0024 — End a durable subscription’s broker state on reload instead of refusing the reload

Status: accepted Date: 2026-10-09 Deciders: GoBridge core Amends: 0003 (the managed subscription history key, and a durable session may now be removed or renamed by a live reload), 0018 (retiring a reload unit may end the broker state the unit leaves behind), 0022 (switching the protocol version keeps the managed subscription history) Relates to: 0011, 0013, 0019, 0020

Context

What the broker keeps

Some subscriptions live on the broker, not in GoBridge, and outlive the connection that made them. The broker files that state under an identity the broker knows, not under GoBridge’s session_id:

When GoBridge changes the identity it uses — a new client ID, another broker, a new container_id or link name — or removes the session, it connects as a different identity, or not at all. The old state stays on the broker:

What v0.7.1 does about it

v0.7.1 refuses a live reload that changes the identity of a Persistent or Exclusive MQTT session, or removes or renames one. The Supervisor, the AWS runtime (through bridge.ValidateDurableReload) and the cluster rollout preflight all run the same comparison. The documented way out is to store the new configuration and restart the task.

That rule protects nothing:

Decision

A live reload accepts a change to a durable subscription’s broker identity, and the removal of the subscription. Retiring the old reload unit ends the old identity’s state on the broker. Nothing is refused, and no restart is needed.

1. Remove the refusal

The durable session identity comparison is deleted from the Supervisor’s apply path, from bridge.ValidateDurableReload (and so from bridge.ValidateDormantReactivation and the AWS runtime’s apply), and from the cluster rollout preflight. The change becomes an ordinary reload: the reload unit that holds the session is retired and the new one is added (ADR 0018), serialized as today.

Two things stay:

2. The broker state key

A broker state key names one piece of broker-side state that outlives a connection. Two equal keys are the same state.

Transport When it has a key The key
MQTT Persistent or Exclusive session the canonical broker endpoint and the effective client ID (what DurableSessionIdentityDomains computes today)
AMQP 1.0 receiver with durability_mode above 0 on a topic (multicast) address the canonical broker endpoint, the container_id and the effective link name
everything else never —

The session mode, clean start, session expiry and MQTT protocol version are not part of the MQTT key; changing them reconnects the same broker session. A receiver on a queue (anycast) address never has a key, so GoBridge never deletes a queue.

Keys are computed from the configuration, not from running instances, by an optional transport factory capability that is given a session and the receivers bound to it. They have to be known before anything is retired: a serialized reload retires the old units before it builds the new ones.

A reload compares the keys of the whole running configuration with the keys of the whole next configuration. A key in the running configuration that is not in the next one is lost. Comparing whole configurations means renaming only a session_id loses nothing, because the broker identity is still there.

3. Retiring ends lost broker state

Runtime.Retire handles a session that holds a lost key in this order:

  1. drain in-flight deliveries, as today;
  2. end the broker state;
  3. close the session;
  4. release its lease.

Only an instance that is connected (MQTT) or attached (AMQP 1.0) at that moment, and that holds the lease when the session is lease-managed, ends anything. A cluster standby never connected as the identity and does nothing.

How the state is ended, through an optional capability of the MQTT session and the AMQP 1.0 receiver:

The step is bounded by the transport’s connect timeout, and is abandoned when it cannot finish before the local deadline of the lease the instance holds. When it fails — access denied, broker unreachable — the session logs a Warn naming session_id and counts the failure in a metric, and the reload continues. The state is then left as it was before this decision: it expires (MQTT) or stays (AMQP 1.0).

A full replacement (prepare-commit or overlap swap) gives the old runtime’s Stop the same set of lost keys.

Nothing else ends broker state: not a shutdown, a restart, a pause (StopBridge), a lease loss or failover, the rebuild of a failed session (ADR 0020), or the reload of a unit whose keys all survive.

4. MQTT managed subscription history

The history is stored under a SHA-256 digest of the MQTT broker state key, so the store still holds no client ID or broker URL. Changing the expiry, clean start, mode or protocol version keeps the history.

Upgrade. When no history exists under the new key, the session reads the history stored under the old fingerprint once and stores it under the new key. The old fingerprint function remains only for that lookup.

A key a reload adds. When a live reload adds a broker state key that the running configuration did not have — a new client ID, or a new durable session — the runtime records an empty history for it unless one already exists. A session that starts with an empty history first ends whatever broker session its client ID may still have, so the broker holds nothing the history does not know. An existing history is kept, never emptied: it describes what the broker may still hold for that client ID, or another cluster member has already filled it, and the reconcile removes the filters the plan no longer has. At process start, with no running configuration to compare with, the existing rule is unchanged: a durable session with no history needs a seeded baseline.

5. Corrections that go with it

Delivery guarantee

What each broker does

Broker Ending the state
MQTT 5 and 3.1.1 brokers The session is deleted, including its shared subscription membership.
ActiveMQ Artemis The subscription queue and its messages are deleted when no other consumer is attached. The user needs the deleteDurableQueue permission.
Qpid Broker-J The durable subscription is deleted.
Solace Not deleted: Solace deletes a durable topic endpoint only on a closing detach with a null source, which go-amqp cannot send. The failure is logged.
RabbitMQ 4 (AMQP 1.0), Service Bus, SQS Nothing to end: these addresses are queues or entities provisioned outside GoBridge.

Consequences

Rejected alternatives