fix(historian): #993 gateway read refusals no longer degrade health, QuestDB reverse events read finds its cut by backward scan, time-weighted aggregator stops allocating per sample
G-9: a gateway-answered InvalidArgument/OutOfRange/NotFound/Unimplemented read is a connectivity observation (open, streak ends), not a failure; outages still degrade. G-17: capped reverse/end-only QuestDB events reads find the n+1-th latest ts with an early-exit backward scan, then read ts >= cut ordered (ts DESC, event_id DESC). G-18: Distribute takes a bridged/nonGood flag instead of per-sample delegates (O(buckets) allocation). QuestDB integration fixture waits up to 60 s for WAL visibility (shared host is CPU-saturated; the 5 s production default made alarm-writer tests read back fewer rows). Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1274,6 +1274,10 @@ says is complete carries no continuation point. `NumValuesPerNode == 0` stays un
|
||||
is forward `[MinValue, EndTime)` everywhere.
|
||||
- **Backends.** The server checks `IHistorianDataSource.SupportsReverseEvents`. SqlServer and QuestDB serve reverse natively
|
||||
(`… > lo AND … <= hi ORDER BY time DESC, id DESC`, the `ReadEventsAsync(…, bool reverse, …)` overload) and report `true`.
|
||||
QuestDB's capped reverse read (G-17, #993) first finds its cut with a backward scan that stops early
|
||||
(`ReverseEventCutSql`: `ORDER BY ts DESC LIMIT n+1`), then reads `ts >= cut` ordered `(ts DESC, event_id DESC)` — the plain
|
||||
`ORDER BY ts DESC, event_id DESC LIMIT n` planned as a forward scan of the whole window (no early exit), so "the latest 1,000
|
||||
alarms" read every event row, again per continuation page; ties at the cut are still chosen by `event_id`.
|
||||
**Gateway reports `false`** — the gateway streams ascending only and rejects `end < start` — and is never sent a reverse
|
||||
read (Null reports `true` and answers empty either way, as for raw): since **#691.4** the server walks it back from bounded **forward** reads with the raw walk (#686/#689/#691:
|
||||
page-sized ms-aligned segments filtered to `(segLo, segHi]`, a read the source flagged truncated is never answered from,
|
||||
@@ -2160,6 +2164,14 @@ The read client reports `GetHealthSnapshot()` (query/failure counters, consecuti
|
||||
`AutoCreateSchema=false`). A SQL connection outage on a read surfaces as `BadNoCommunication`; other SQL errors retain `BadHistoryOperationUnsupported` for **that node only**; a cancelled read
|
||||
(deadline, client abort) is not counted as a backend fault.
|
||||
|
||||
**Gateway: a request refusal is not an outage (G-9, #993).** On the Gateway backend a read the gateway *answered* with
|
||||
`InvalidArgument` / `OutOfRange` / `NotFound` / `Unimplemented` (`GatewayErrorReasons.IsRequestRefusal` — a bad window or tag name from the
|
||||
client; `FailedPrecondition` is NOT in the set, the gateway also passes historian-side rejections through it) proves the gateway is
|
||||
reachable: it is rethrown as before but is a connectivity observation only — `ProcessConnectionOpen`/`EventConnectionOpen` stay `true`, the
|
||||
consecutive-failure streak ends, and no failure counter moves (like the aggregate-not-supported and `MaxValuesCeiling` refusals). Transport
|
||||
statuses (`Unavailable`, `DeadlineExceeded`), `Internal`, `Unknown` and non-RPC exceptions still degrade health. A client polling HistoryRead
|
||||
with a bad argument used to hold `/hosts` at "connection closed" with a growing failure count against a healthy gateway.
|
||||
|
||||
### Retention (`RetentionDays`)
|
||||
|
||||
`hist.Sample`, `hist.SampleModified` and `hist.Event` grow without bound unless `ServerHistorian:SqlServer:RetentionDays` is set. QuestDB already has an
|
||||
@@ -2528,6 +2540,12 @@ docker compose -f docker-dev/docker-compose.yml -f docker-dev/docker-compose.que
|
||||
export HISTORIAN_QUESTDB_TEST_CONNECTION='Host=localhost;Port=18812;Username=admin;Password=quest;Database=qdb;ServerCompatibilityMode=NoTypeLoading'
|
||||
```
|
||||
|
||||
Tests wait for WAL visibility up to `QuestDbFixture.VisibilityTimeout` (60 s; env `HISTORIAN_QUESTDB_TEST_VISIBILITY_SECONDS`), not the
|
||||
production 5 s: the shared fixture's Docker host is routinely CPU-saturated (load average in the hundreds on 22 cores, 2026-12-03 — CI jobs,
|
||||
Ignition), QuestDB applies WAL commits late, `WaitAsync` gives up with only a Warning to a null logger, and a test then reads back FEWER rows
|
||||
than it wrote (the "0 rows on master" alarm-writer symptom, #993). Fixture state itself was clean (4 tables, none suspended, `sequencerTxn -
|
||||
writerTxn = 0`); it is load, not collision.
|
||||
|
||||
`admin` / `quest` is QuestDB's stock default — a throwaway fixture credential, not a secret. The fixture's compose file is
|
||||
`tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.QuestDb.IntegrationTests/Docker/docker-compose.yml` (label `project=lmxopcua`).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user