fix(deploy): #1107 re-send the deploy dispatch to nodes that have not acked

ConfigPublishCoordinator dispatched a deployment exactly once: on DPS a node whose
deployments registry entry had not gossiped to central missed it (#1106), on gRPC a
failed dial was dropped, and either way the deployment timed out at 120 s.

Coordinator: re-sends the same DispatchDeployment at +5/+15/+35 s (bounded by half the
remaining deadline) with the new additive TargetNodes naming only expected nodes whose
ack has not arrived (an ack still being persisted counts). Stops on last ack,
completion, time-out, supersede or schedule end; a recovered in-flight deployment gets
the same re-send. Counter otopcua.deploy.redispatched.

Transport: CentralCommunicationActor's gRPC fan dials only the named nodes; proto gains
repeated target_nodes = 4 (additive). On DPS, non-addressed nodes ignore the re-send.

Node (DriverHostActor): a re-send is idempotent per DeploymentId — ignored if not
addressed here or mid-apply; ANY copy of a deployment whose Applied ack is held on the
address-space outcome no longer starts a second apply; a re-send of a deployment it
already acked re-delivers the remembered ack (last 16) instead of re-applying (#601
would otherwise re-apply a degraded revision). Original dispatches are unchanged.

Docs: Redundancy.md §Dispatch re-send, Configuration.md, cluster-topology rule.
This commit is contained in:
Joseph Doherty
2026-12-04 22:29:17 -05:00
parent da23fd970d
commit 323bbd2a63
14 changed files with 860 additions and 23 deletions
+1 -1
View File
@@ -225,7 +225,7 @@ Security__Ldap__GroupToRole__<AD group>=Viewer
| `Mode` | string | `Dps` | `Dps` = DistributedPubSub, pair-local only — cannot cross an application-`Cluster` boundary. `Grpc` = the `mesh_transport.v1` gRPC contract (below), required on any node carrying a `cluster-{ClusterId}` role. Any other value **refuses to start**, including the retired `ClusterClient` value — a node still configured for it is refused at boot rather than silently demoted to `Dps`, which on a split-topology node would deliver nothing at all. |
| `ContactRefreshSeconds` | int | `60` | Central-side only: how often central rebuilds its node dispatch set — the gRPC dial targets and the known-cluster PSK gate — from the `ClusterNode` rows. Runs in every mode; under `Dps` it still keeps the inbound-ack endpoint's known-cluster gate current even though nothing dials out. While the known-cluster gate is still unpublished (PSK provider not yet resolvable at boot, or the first `ClusterNode` load failed) central also retries a refresh every 2 s, at most 15 times, until the first publish (#654); steady state adds no traffic. Load failures and an unresolvable provider share the one 15-retry (~30 s) budget; after it is spent, healing falls to the periodic refresh. |
**`Grpc` mode: central dials each node, a node posts its ack to central.** `CentralCommunicationActor` fans one `NodeCommandService.Execute` call per node — the target set is every enabled, non-maintenance `ClusterNode` row that carries a `GrpcPort` (dialled at `Host`+`GrpcPort`), rebuilt every `ContactRefreshSeconds`. There is no receptionist and no single fleet-wide (or per-cluster) client object: it is a plain per-node dial. A node posts its `ApplyAck` with `GrpcApplyAckSender`, which walks `CentralGrpcEndpoints` in order and stops at the first success — an availability list, not a fan-out list, so central normally sees one ack per node per dispatch (the walk as a whole is at-least-once on a slow-then-retried endpoint; `ConfigPublishCoordinator.HandleAck` absorbs a duplicate idempotently). Both directions are **fire-and-forget, with no retry**: a failed dispatch is logged (naming the node and the gRPC status) and dropped in the dispatch second — the deploy path's 2-minute apply deadline and a node's boot-time replay (`DriverHostActor.Bootstrap()` re-applying an orphan `Applying` row) are the only recovery mechanisms, exactly as they were under `ClusterClient`.
**`Grpc` mode: central dials each node, a node posts its ack to central.** `CentralCommunicationActor` fans one `NodeCommandService.Execute` call per node — the target set is every enabled, non-maintenance `ClusterNode` row that carries a `GrpcPort` (dialled at `Host`+`GrpcPort`), rebuilt every `ContactRefreshSeconds`. There is no receptionist and no single fleet-wide (or per-cluster) client object: it is a plain per-node dial. A node posts its `ApplyAck` with `GrpcApplyAckSender`, which walks `CentralGrpcEndpoints` in order and stops at the first success — an availability list, not a fan-out list, so central normally sees one ack per node per dispatch (the walk as a whole is at-least-once on a slow-then-retried endpoint; `ConfigPublishCoordinator.HandleAck` absorbs a duplicate idempotently). Both directions are **fire-and-forget at the transport, with no retry**: a failed dispatch is logged (naming the node and the gRPC status) and dropped in the dispatch second. Deployments are the exception one layer up: `ConfigPublishCoordinator` re-sends a dispatch to the nodes that have not acked (#1107, [Redundancy.md § Dispatch re-send](Redundancy.md#dispatch-re-send-gitea-1107)), and the 2-minute apply deadline and a node's boot-time replay (`DriverHostActor.Bootstrap()` re-applying an orphan `Applying` row) remain the backstops.
The ack itself is sent only once the node's address-space apply outcome is known, and carries an additive `degraded` flag (`ApplyAckMessage` fields 6/7; trailing `ApplyAck.Degraded`/`DegradedReason` on DPS) — an old node's ack decodes clean, exactly as before. See [Redundancy.md § "What an `Applied` ack means"](Redundancy.md#what-an-applied-ack-means-the-degraded-apply-amendment-gitea-601) (Gitea #601).
+32 -3
View File
@@ -809,10 +809,39 @@ Two properties are load-bearing and easy to break:
- **Inbound commands go to the node-local `EventStream`, never back onto a DPS topic.** DPS is
mesh-wide and central fans out to *every* node, so a DPS re-publish would deliver N copies of
every command to every subscriber.
- **Both transports are fire-and-forget, with no retry or queue.** A failed gRPC dispatch is logged
(naming the node and the gRPC status) and dropped in the dispatch second — the deploy path's
- **Both transports are fire-and-forget at the transport layer, with no retry or queue.** A failed gRPC
dispatch is logged (naming the node and the gRPC status) and dropped in the dispatch second. Driver-control
and alarm commands stay that way. **Deployments are re-sent by the deploy coordinator** (below); the
2-minute apply deadline and a node's boot-time replay (`DriverHostActor.Bootstrap()` re-applying an
orphan `Applying` row) are the only recovery mechanisms, unchanged from the DPS/`ClusterClient` era.
orphan `Applying` row) remain the backstops.
### Dispatch re-send (Gitea #1107)
Until #1107 `ConfigPublishCoordinator` dispatched a deployment exactly once. On DPS a node whose
`deployments` registry entry had not yet gossiped to the publisher missed it (#1106); on gRPC a failed
dial was dropped — either way the deployment sat until the 120 s deadline and sealed `TimedOut`. Now:
- **Re-sent, bounded, to un-acked nodes only.** At +5 s, +15 s and +35 s
(`ConfigPublishCoordinator.DefaultRedispatchSchedule`, and never past half of the remaining deadline) the
coordinator re-sends the SAME `DispatchDeployment` (same `DeploymentId`/`RevisionHash`/`CorrelationId`)
with `TargetNodes` naming the expected nodes whose ack has not **arrived** — an ack still being persisted
counts as arrived. Re-sends stop at the last ack, completion, time-out, supersede, or the end of the
schedule; a recovered in-flight deployment (singleton fail-over) gets the same re-send inside what is left
of its deadline. Counter: `otopcua.deploy.redispatched` (per targeted node).
- **Why only un-acked nodes:** under #601 a same-revision dispatch makes a node whose last apply was
degraded *re-apply*. On gRPC central dials only the named nodes; on DPS the publish reaches every node and
`DispatchDeployment.IsAddressedTo` makes the others ignore it.
- **A re-send is idempotent on the node, per `DeploymentId`.** Mid-apply it is dropped (the existing
in-flight dedup); while the Applied ack is held on the address-space outcome, ANY copy of that deployment
is ignored (no second apply); once the node has acked, a re-send re-delivers the remembered ack (the last
16 deployments) instead of applying again — so a lost ack is recovered and a duplicate ack is harmless
(the coordinator re-persists the same outcome, or discards it as stale). An ORIGINAL dispatch is unchanged:
re-dispatching a degraded revision still re-applies.
- **Residuals.** A pre-#1107 node on the **DPS** transport ignores `TargetNodes`, so during a rolling upgrade
it can re-apply on a re-send meant for its peer (gRPC is unaffected — central filters). The node's memory
is process-local: a node that restarted after acking treats a re-send as a first dispatch (short-circuit,
or a re-apply if its revision is unconfirmed). A node that first receives the dispatch at +35 s still has
~85 s to ack; only a rebuild slower than that, which already acks degraded at 105 s, can miss the deadline.
### What an `Applied` ack means: the degraded-apply amendment (Gitea #601)