Merge #976: historian outages never dead-letter alarm history; gateway transient codes retry; outbox ack never drops an unindexed append
This commit is contained in:
+40
-5
@@ -59,7 +59,9 @@ unless noted.
|
||||
- **`HistorianWriteOutcome`** — per-event drain result: `Ack` (persisted,
|
||||
remove from queue), `RetryPlease` (transient failure — leave queued, retry
|
||||
after backoff), `PermanentFail` (malformed/unrecoverable — move to
|
||||
dead-letter).
|
||||
dead-letter). Writers return `PermanentFail` only when the failure proves the
|
||||
EVENT bad; anything that could be an outage is `RetryPlease` (#976 — see
|
||||
"Outages never dead-letter" below).
|
||||
- **`HistorianSinkStatus`** — diagnostic snapshot surfaced to the AdminUI and
|
||||
`/healthz`: `QueueDepth`, `DeadLetterDepth`, `LastDrainUtc`, `LastSuccessUtc`,
|
||||
`LastError`, `DrainState`, and `EvictedCount`.
|
||||
@@ -192,10 +194,11 @@ lifetime belong to LocalDb; the sink no longer manages either.
|
||||
each outcome is applied in one transaction: `Ack` deletes the row (the delete
|
||||
replicates as a tombstone, so the peer drops its copy and a promoted standby
|
||||
cannot re-send it), `PermanentFail` flips its `dead_lettered` flag,
|
||||
`RetryPlease` bumps its attempt
|
||||
count and leaves it queued. A row whose `AttemptCount` has reached the configured
|
||||
**`MaxAttempts`** cap (default 10) is dead-lettered automatically on the next drain
|
||||
tick rather than retried — this breaks infinite retry loops for poison events whose
|
||||
`RetryPlease` leaves it queued — and, **only on a drain where at least one event was
|
||||
`Ack`'d** (the historian is demonstrably accepting writes), bumps its attempt count.
|
||||
A row whose `AttemptCount` has reached the configured
|
||||
**`MaxAttempts`** cap (default 10) is dead-lettered automatically on the next such drain
|
||||
rather than retried — this breaks infinite retry loops for poison events whose
|
||||
payload the historian will always reject (e.g. a malformed alarm record that triggers
|
||||
a permanent SDK error on every attempt). The dead-lettered row remains inspectable
|
||||
via `RetryDeadLettered()` for the configured retention window.
|
||||
@@ -209,6 +212,38 @@ BackingOff`; a clean batch resets it. The async-void timer callback is fully
|
||||
guarded: a fault is logged and recorded into `GetStatus()` rather than lost as
|
||||
an unobserved task exception.
|
||||
|
||||
### Outages never dead-letter (#976)
|
||||
|
||||
Every production writer answers a systemic failure — historian, HistorianGateway or
|
||||
database down, an auth blip, a failed schema bootstrap, a gateway restart answering
|
||||
`Cancelled`/`Unknown`, a dropped channel — with `RetryPlease` for every event of the
|
||||
batch. Until #976 the sink counted each of those against `MaxAttempts`, so an outage
|
||||
longer than ~6.5 minutes (1 + 2 + 5 + 15 + 60 s, then 60 s per drain, 10 attempts)
|
||||
dead-lettered the oldest 100 queued alarm events, and another 100 every ~10 minutes
|
||||
after that, with no automatic retry. Now:
|
||||
|
||||
- A drain with **no `Ack`** is treated as an outage: `RetryPlease` rows are left
|
||||
exactly as they were (no attempt counted, nothing dead-lettered), the backoff climbs
|
||||
to its 60 s cap, `DrainState = BackingOff` and `LastError` reads "Historian
|
||||
unavailable: N event(s) deferred …". `PermanentFail` rows still dead-letter. When the
|
||||
historian returns, the queue drains in `enqueued_at_utc` order.
|
||||
- `MaxAttempts` therefore bounds only a row that keeps failing **while its neighbours
|
||||
land** — the finding-002 poison case it exists for.
|
||||
- Writers: `GatewayAlarmHistorianWriter` dead-letters only `InvalidArgument`,
|
||||
`FailedPrecondition`, `OutOfRange`, `NotFound`, `AlreadyExists`, `Unimplemented` (on
|
||||
a single send) and events that cannot be mapped to the wire; every other gRPC code and
|
||||
every non-RPC exception retries (the default used to be dead-letter). The SQL writers
|
||||
dead-letter only recognised data errors, and `AlarmBatchWrite` re-sends a multi-event
|
||||
chunk **event by event** when it fails with an error that is neither a recognised data
|
||||
error nor a known transient, so one unrecognised poison event cannot hold its
|
||||
chunk-mates (they `Ack`, which is what lets the sink count the poison row's attempts).
|
||||
- Residual: a batch made up **entirely** of rows that always answer `RetryPlease` looks
|
||||
like an outage and is retried at the 60 s cap rather than dead-lettered. It shows as a
|
||||
queue that does not drain while `LastError` reports the deferral.
|
||||
- Rows dead-lettered as `max attempts (N) exceeded` before #976 may be outage
|
||||
casualties; `RetryDeadLettered()` revives them. Rows dead-lettered by a post-#976 node
|
||||
read `… exceeded while the historian accepted other events`.
|
||||
|
||||
### Durability bound (important)
|
||||
|
||||
**The durability guarantee is bounded by `capacity` (default 1,000,000 rows).**
|
||||
|
||||
@@ -431,6 +431,12 @@ because the outbox's `RemoveAsync` truncates the FIFO head *through* the acked i
|
||||
entries could silently drop older, unwritten entries belonging to another. That much is deliberate and
|
||||
unchanged.
|
||||
|
||||
**Through, and no further (#976 G-7).** The recorder's append loop runs concurrently with the drain, and an append
|
||||
enqueues a record before it indexes it. Acking the newest indexed entry used to truncate to the log's live tail — past a
|
||||
value enqueued in that window, which was then silently never historized (and gone after a restart). The truncation point
|
||||
is now the acked record's own end (the address the drain's peek scanned past it), and a peek returns only indexed
|
||||
records, so every value it hands the drain can be acked.
|
||||
|
||||
What was wrong is what happened when a tag failed **permanently**: the head never advanced, so every
|
||||
**healthy** tag in the batch was re-submitted to the historian on every drain pass, indefinitely —
|
||||
duplicate samples at identical timestamps, and an outbox that never truncated (observed live at 8.3 MB
|
||||
@@ -1717,6 +1723,10 @@ with the first HistoryUpdate after it.
|
||||
Outcomes: `Ack` on insert or already-present (including a concurrent writer winning a 2627/2601 race); `RetryPlease` on
|
||||
transient SQL errors (connection, timeout, deadlock 1205 …), bootstrap failures, cancellation and any unclassified error;
|
||||
`PermanentFail` (dead-letter) only for data errors SQL will reject forever (truncation 2628/8152, conversion, null, range, constraint).
|
||||
A multi-event chunk failing with an error that is neither a recognised data error nor a known transient (#976) is also
|
||||
re-sent event by event, so an unrecognised poison event no longer retries its chunk-mates with it; the store-and-forward
|
||||
sink counts a `RetryPlease` against `MaxAttempts` only on a drain where something was `Ack`'d, so an outage never
|
||||
dead-letters (`docs/AlarmHistorian.md` §"Outages never dead-letter").
|
||||
`SourceName` is the event's `EquipmentPath`; `Severity` is the numeric Part 9 value (Low 200, Medium 500, High 700, Critical 900).
|
||||
- **Tag names** are `nvarchar(400)`, and a longer name is **refused, never truncated** (a truncating parameter would resolve
|
||||
it onto whichever tag owns its first 400 characters): `EnsureTags` fails it individually, the live-value writer returns
|
||||
|
||||
Reference in New Issue
Block a user