Stop consumers from committing past failed offsets, harden Rabbit/DataLake/gateway backpressure, dispose JsonDocument/MinIO correctly, and batch expensive DB/HTTP paths. Track progress in docs/performance.
2.1 KiB
2.1 KiB
Phase 41 — Correctness & Backpressure
| Field | Value |
|---|---|
| Status | Complete |
| Audit findings | 1, 2, 3, 7 |
| Depends on | Docs roadmap |
Goal
Stop silent Kafka message loss, make RabbitMQ channel use safe under concurrency, and hard-cap DataLake / gateway buffers so outages produce lag instead of OOM or unbounded disk growth.
What exists
- Kafka consumers use
PoisonPillGuardand log “will retry” but do notSeekafter transient failure - Escalation / clinical sync / discharge / local escalation use
prefetchCount: 5with sharedIModel DataLakeWriterServiceretains failed partition buffers while continuing to consumeBufferedSyncWriter.Enqueuehas no depth limit
What to build
- Shared Kafka Seek-on-retry helper used by all scoring / indexing / notification consumers
- NotificationPublisher: Seek + delay on transient failure (same as scorers)
- Unit tests for Seek-retry behavior; keep PoisonPillGuard tests green
- RabbitMQ
prefetchCount: 1on Escalation, ClinicalSync, DischargeSummary, LocalEscalation DataLakeOptions.MaxBufferedEvents+ pause/skip buffer when at cap after failed flush- Gateway sync buffer max depth (config) with reject when full (
SYNC_BUFFER_FULL)
Key files
VigilCareClinicalAPI/Infrastructure/PoisonPillGuard.csVigilCareClinicalAPI/BackgroundServices/*ScoringService.cs,EsIndexerService.cs,NotificationPublisherService.csVigilCareClinicalAPI/DataLake/DataLakeWriterService.cs,DataLakeOptions.cs- Rabbit workers under
BackgroundServices/Notifications/and WardLocalEscalationWorkerService VigilCare.WardGateway/Services/BufferedSyncWriter.cs
Acceptance criteria
- Transient failure re-seeks to the same offset until success or intentional poison skip
- Rabbit workers with former prefetch 5 now use prefetch 1
- Forced MinIO / central outage: buffers plateau at configured caps
- Affected unit tests green
Verification notes
- Added
KafkaConsumerRetry+ unit tests for Seek vs poison Commit. - Consumers wired to helper; Rabbit prefetch set to 1; DataLake/Gateway caps configured (50_000 default).