Code review 2026-12-02 WP4: Cross-cluster, failover and central singletons #155

Closed
opened 2026-12-02 16:06:55 -05:00 by dohertj2 · 1 comment
Owner

From the 2026-12-02 full code review (commits 28b6651a, f7e4f5b4: decisions accepted 2026-12-03).

  • Findings: docs/plans/2026-12-02-full-code-review.md
  • Plan: docs/plans/2026-12-02-full-code-review-remediation.md → WP4
Task Findings Change Verify
4.1 COMM-1, COMM-6 Health sequence = max(prev+1, nowMs), re-seeded on the standby→active transition. Reset interval counters on activation. The aggregator returns Accepted=false on a drop. Aggregator tests. Failover drill with a deliberately skewed start.
4.2 COMM-2 A site node refuses SiteStreamService subscriptions with Unavailable while it isn't SelfIsOldestUp for its site role, and ends its streams on losing the active role. gRPC server test. Rig: restart NodeA after a failover, then check that Alarm Summary and Debug View go live on NodeB.
4.3 COMM-3, COMM-7 Debug stream: buffer events until the snapshot is delivered, and handle the snapshot Status.Failure. Bridge actor tests.
4.4 COMM-4, COMM-5 Key liveness on central receive time. Set SocketsHttpHandler.ConnectTimeout on the gRPC channels and treat a connect-phase DeadlineExceeded as failover-worthy. Tests. Black-hole drill (iptables drop) on the rig.
4.5 NTF-1 Write the outbox's delivered state with a non-shutdown token. Test with the stop token cancelled mid-delivery.
4.6 NTF-2, ESG-1 Classify SMTP connection drops, OAuth2 token-endpoint outages, and a body-read IOException/HttpRequestException as transient. Adapter tests.
4.7 DLM-1 DelmiaNotifier: a connect failure (no request sent) fails over to the next URL; OUTCOME_UNKNOWN only after the send. Notifier tests.
4.8 AUD-1 Reconciliation keeps one cursor per (site, node) and pulls from both nodes. Reconciliation tests.
4.9 SCA-1 Decided: Parked can be re-opened, end to end. The site tracking store accepts a transition out of Parked: Retry clears TerminalAtUtc, Discard writes Discarded, and both emit telemetry. The central guard accepts Parked → Attempted/Delivered/Failed/Discarded when the incoming UpdatedAtUtc is newer. A separate reconcile sweep of parked rows was rejected because it adds a second path. Test. Rig: retry a parked call and watch the row clear.
4.10 KPI-1 The backfill plans from its own persisted watermark, not from the periodic fold's. Recorder test.
4.11 AUD-6 The purge/archive covers rows before the first partition boundary. SQL test against a partitioned test DB.
From the 2026-12-02 full code review (commits 28b6651a, f7e4f5b4: decisions accepted 2026-12-03). - Findings: `docs/plans/2026-12-02-full-code-review.md` - Plan: `docs/plans/2026-12-02-full-code-review-remediation.md` → WP4 | Task | Findings | Change | Verify | |---|---|---|---| | 4.1 | COMM-1, COMM-6 | Health sequence = `max(prev+1, nowMs)`, re-seeded on the standby→active transition. Reset interval counters on activation. The aggregator returns `Accepted=false` on a drop. | Aggregator tests. Failover drill with a deliberately skewed start. | | 4.2 | COMM-2 | A site node refuses `SiteStreamService` subscriptions with `Unavailable` while it isn't `SelfIsOldestUp` for its site role, and ends its streams on losing the active role. | gRPC server test. Rig: restart NodeA after a failover, then check that Alarm Summary and Debug View go live on NodeB. | | 4.3 | COMM-3, COMM-7 | Debug stream: buffer events until the snapshot is delivered, and handle the snapshot `Status.Failure`. | Bridge actor tests. | | 4.4 | COMM-4, COMM-5 | Key liveness on central receive time. Set `SocketsHttpHandler.ConnectTimeout` on the gRPC channels and treat a connect-phase `DeadlineExceeded` as failover-worthy. | Tests. Black-hole drill (iptables drop) on the rig. | | 4.5 | NTF-1 | Write the outbox's delivered state with a non-shutdown token. | Test with the stop token cancelled mid-delivery. | | 4.6 | NTF-2, ESG-1 | Classify SMTP connection drops, OAuth2 token-endpoint outages, and a body-read `IOException`/`HttpRequestException` as transient. | Adapter tests. | | 4.7 | DLM-1 | DelmiaNotifier: a connect failure (no request sent) fails over to the next URL; `OUTCOME_UNKNOWN` only after the send. | Notifier tests. | | 4.8 | AUD-1 | Reconciliation keeps one cursor per (site, node) and pulls from both nodes. | Reconciliation tests. | | 4.9 | SCA-1 | **Decided:** `Parked` can be re-opened, end to end. The site tracking store accepts a transition out of `Parked`: Retry clears `TerminalAtUtc`, Discard writes `Discarded`, and both emit telemetry. The central guard accepts `Parked → Attempted/Delivered/Failed/Discarded` when the incoming `UpdatedAtUtc` is newer. A separate reconcile sweep of parked rows was rejected because it adds a second path. | Test. Rig: retry a parked call and watch the row clear. | | 4.10 | KPI-1 | The backfill plans from its own persisted watermark, not from the periodic fold's. | Recorder test. | | 4.11 | AUD-6 | The purge/archive covers rows before the first partition boundary. | SQL test against a partitioned test DB. |
dohertj2 added the type:review-findingpriority:p1 labels 2026-12-02 16:06:55 -05:00
Author
Owner

Fixed on main (pushed, 922021c4). Plan: docs/plans/2026-12-02-full-code-review-remediation.md (see its Outcome section).

All 11 tasks done, without touching DeploymentService.

Rig:

  • DRILL_MODE=active failover drill PASS: takeover 25 s, Traefik 28 s, the killed node rejoins as standby.
  • After restarting site-a-a, the standby refused the stream with Unavailable and central streamed from site-a-b (114 live changes in 30 s).
  • 4.9 parked Retry: not live-tested, because the rig had no real parked row. It is listed on #160 for QA.

Migration: AddKpiRollupBackfillState (persisted backfill marker). The first recorder start folds the whole raw window once.

New option: ScadaBridge:Communication:GrpcConnectTimeout, default 5 s.

Commits:

  • f9af0139 migration: AddKpiRollupBackfillState (KPI-1, WP4 task 4.10)
  • e719e902 fix(audit): purge/archive also cover partition 1 (rows before the first boundary) (AUD-6, WP4 task 4.11)
  • 2a41122a fix(kpi): rollup backfill plans from its own persisted watermark, not the periodic fold's MAX (KPI-1, WP4 task 4.10)
  • 5c67559a fix(sitecalls): Parked is re-openable end to end — operator Retry/Discard reach the site tracking row and central SiteCalls (SCA-1, WP4 task 4.9)
  • 4070f7ef fix(audit): reconciliation pulls every site node with a per-(site, node) cursor (AUD-1, WP4 task 4.8)
  • c15bd210 fix(delmia,inbound): a connect-phase failure (unreachable host, connect timeout) fails over to the next URL/peer instead of OUTCOME_UNKNOWN (DLM-1, WP4 task 4.7)
  • 11992075 fix(notify,esg): classify dropped SMTP connections, OAuth2 token-endpoint outages and body-read connection loss as transient (NTF-2, ESG-1, WP4 task 4.6)
  • 5f7b850a fix(outbox): persist a delivery outcome on its own token, not the shutdown token (NTF-1, WP4 task 4.5)
  • f02fe9d6 fix(comm): key site liveness on central receive time; gRPC connect timeout + connect-phase deadline failover (COMM-4, COMM-5, WP4 task 4.4)
  • c1db7094 fix(comm): fold post-snapshot debug events into the snapshot and fail fast on a snapshot-request failure (COMM-3, COMM-7, WP4 task 4.3)
  • 8a4b466a fix(comm): site stream server refuses/ends subscriptions on a non-active node with Unavailable (COMM-2, WP4 task 4.2)
  • 34527374 fix(health): wall-clock-anchored report sequence, nack stale reports, drain standby counters (COMM-1, COMM-6, WP4 task 4.1)

Deploying to QA and DEV is tracked in #160. Closing.

Fixed on `main` (pushed, `922021c4`). Plan: `docs/plans/2026-12-02-full-code-review-remediation.md` (see its Outcome section). All 11 tasks done, without touching `DeploymentService`. **Rig:** - `DRILL_MODE=active` failover drill PASS: takeover 25 s, Traefik 28 s, the killed node rejoins as standby. - After restarting site-a-a, the standby refused the stream with `Unavailable` and central streamed from site-a-b (114 live changes in 30 s). - **4.9 parked Retry:** not live-tested, because the rig had no real parked row. It is listed on #160 for QA. **Migration:** `AddKpiRollupBackfillState` (persisted backfill marker). The first recorder start folds the whole raw window once. **New option:** `ScadaBridge:Communication:GrpcConnectTimeout`, default 5 s. **Commits:** - f9af0139 migration: AddKpiRollupBackfillState (KPI-1, WP4 task 4.10) - e719e902 fix(audit): purge/archive also cover partition 1 (rows before the first boundary) (AUD-6, WP4 task 4.11) - 2a41122a fix(kpi): rollup backfill plans from its own persisted watermark, not the periodic fold's MAX (KPI-1, WP4 task 4.10) - 5c67559a fix(sitecalls): Parked is re-openable end to end — operator Retry/Discard reach the site tracking row and central SiteCalls (SCA-1, WP4 task 4.9) - 4070f7ef fix(audit): reconciliation pulls every site node with a per-(site, node) cursor (AUD-1, WP4 task 4.8) - c15bd210 fix(delmia,inbound): a connect-phase failure (unreachable host, connect timeout) fails over to the next URL/peer instead of OUTCOME_UNKNOWN (DLM-1, WP4 task 4.7) - 11992075 fix(notify,esg): classify dropped SMTP connections, OAuth2 token-endpoint outages and body-read connection loss as transient (NTF-2, ESG-1, WP4 task 4.6) - 5f7b850a fix(outbox): persist a delivery outcome on its own token, not the shutdown token (NTF-1, WP4 task 4.5) - f02fe9d6 fix(comm): key site liveness on central receive time; gRPC connect timeout + connect-phase deadline failover (COMM-4, COMM-5, WP4 task 4.4) - c1db7094 fix(comm): fold post-snapshot debug events into the snapshot and fail fast on a snapshot-request failure (COMM-3, COMM-7, WP4 task 4.3) - 8a4b466a fix(comm): site stream server refuses/ends subscriptions on a non-active node with Unavailable (COMM-2, WP4 task 4.2) - 34527374 fix(health): wall-clock-anchored report sequence, nack stale reports, drain standby counters (COMM-1, COMM-6, WP4 task 4.1) Deploying to QA and DEV is tracked in #160. Closing.
Sign in to join this conversation.