fix(audit): reconciliation pulls every site node with a per-(site, node) cursor (AUD-1, WP4 task 4.8)

This commit is contained in:
Joseph Doherty
2026-12-03 10:08:20 -05:00
parent c15bd210f7
commit 4070f7efca
10 changed files with 514 additions and 60 deletions
+15
View File
@@ -396,6 +396,21 @@ issues `PullAuditEvents(sinceUtc, batchSize[, afterId])` against each site and
inserts-if-not-exists. Same self-healing pattern as Site Call Audit's
reconciliation of `SiteCalls`.
**Both nodes, one cursor each (AUD-1, 2026-12).** The site audit store is a
per-node, unreplicated SQLite file, so each node owes its own rows. Every tick
pulls **every configured node** of the site (`GrpcNodeAAddress` and a distinct
`GrpcNodeBAddress`) through `IPullAuditEventsClient.PullFromEndpointAsync` —
one node, no NodeA→NodeB failover — and keeps a composite cursor per
**(site, node endpoint)**. Before, the pull went to NodeA whenever NodeA
answered: after any NodeA restart (NodeB active, NodeA a healthy standby with an
empty store) every pull reported "drained" and NodeB's `PushAbandoned`/`Rejected`
rows never reached central; and the single per-site cursor, fed by NodeA's rows,
could be sent to NodeB, skipping NodeB's owed rows and letting
`MarkReconciledUpToAsync` retire rows central never received. One node failing
does not skip the other; the stalled latch stays per site (non-draining when any
node is). An edited address drops that node's cursor and starts the new one from
the beginning of what it owes.
**The pull serves only rows central has not acknowledged (review 2026-10-21
06/PERF-1).** `ReadPendingSinceAsync` returns `Pending`, `PushAbandoned` and
`Rejected` rows — never `Forwarded`. It used to serve `Forwarded` rows too, so
@@ -120,6 +120,13 @@ reconnect — pulls "all tracking rows changed since cursor X" from each site.
Gaps left by lost telemetry self-heal. Central converges to the site; the site
never depends on central.
**Every node is pulled, each with its own cursor (AUD-1, 2026-12).** On a site
pair without LocalDb replication each node's operation-tracking store is its
own, so the pass pulls every configured node (`PullFromEndpointAsync`, no
NodeA→NodeB failover) and keys the cursor below per **(site, node endpoint)**;
the pinned latch stays per site (pinned when any node is). Before, NodeA was
pulled whenever it answered, so a standby NodeA's empty store hid NodeB's rows.
The per-site cursor is a **composite `(UpdatedAtUtc, TrackedOperationId)`
keyset**, not a single timestamp. Each pull asks for rows strictly greater than
the cursor pair and advances it to the maximum row seen; a burst of more rows