Repository navigation
refactor(alerts): alert rows own the state and consumers declare their kind - #33971
Conversation
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
✅ Generated Sources Auto-UpdatedThe generated TypeScript types ( |
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
…health stores only what ticks report
…channel is grouped from
…stopping flag and recipient lookups
…ed once and health per destination
…, fails the event with its reason
🚦 Removed from the merge queue —
|
Code Review ✅ Approved 2 closed / 2 findings🟡 Medium risk · Alert delivery, cursor persistence, and destination health now use a new ledger. Refactors alert state out of the scheduler's job data into dedicated ledger rows, with each consumer declaring its kind. Fixes stale destination health by reading from stored state only and ensures opening notes survive failed commits to properly track failed events. No issues found. ✅ 2 closed✅ Bug: Stored health overrides destination enabled flag (stale Disabled/Active)
✅ Edge Case: Opening note survives a failed commit, so the next event can be set aside
OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
|



Fixes #34265
What this pull request implements
An alert's running state moves out of the scheduler's job data into rows of its own: its position in the change log, its wait for a gap, its counters, each destination's health, the events it delivered and its failures. Every tick reads the alert's stored row first. Each consumer declares its kind.
What was wrong before
The state lived in the Quartz job data, and when a tick ended the scheduler wrote the job data it started with back over the job. An edit made while the alert was running, a switch-off or a skipped backlog was undone, and destination health was reset on every edit and restart. Nothing recorded which event a tick was working on, so a change that stopped the server every time an alert processed it was read again after every restart.
Design
flowchart TD subgraph CALLERS["Callers"] direction LR SCHED["EventSubscriptionScheduler"] REPO["EventSubscriptionRepository"] TICK["AlertTick: reads the stored alert first"] CONSUMER["Consumer of kind EVENT, BATCH or SELF_DRIVEN"] end subgraph PLANE["Ledger package: creates, opens and writes the rows"] direction LR RECORD["AlertRecord"] LEDGER["AlertLedger, one per tick"] end subgraph ROWS["The alert's rows: what it has done"] direction LR STATE["change_event_consumers: position, counters, gap wait, health, event in progress"] SENT["successful_sent_change_events: delivered"] DLQ["consumers_dlq: failed"] end TICK -->|runs the one the alert names| CONSUMER SCHED -->|creates rows, reads health and position| RECORD REPO -->|skips the backlog| RECORD TICK -->|opens the ledger| RECORD RECORD -->|creates| LEDGER CONSUMER -->|reports to| LEDGER RECORD -->|creates, skips the backlog| STATE LEDGER -->|position by compare-and-set, then the rest| STATE LEDGER --> SENT LEDGER --> DLQAlertTickstarts every tick. The stored alert is the authority: the tick reads its row, does nothing for an alert that is gone or switched off, then opens the ledger and runs the consumer the row names.AlertLedgercollects what one tick leaves behind and writes once, at commit: the position first, by compare-and-set against the document it opened with, then the counters, then the rest as best effort. A position someone else moved in the meantime is never overwritten.AlertRecordcreates an alert's rows and opens them for a tick.AlertRowsis the one way to read the stored alert: its own row, uncached, then its notification template. Only the alert's own row says whether it is gone.BatchConsumerorSelfDrivenConsumer; one that implements neither handles events one by one.ConsumerKind.ofreads it from the class without building the consumer. A consumer that makes its own work is counted by what it reported and has no backlog of change events.HealthStreakcounts each destination's failed ticks in a row.What users notice
For code built on OpenMetadata
A subclass of
AbstractEventConsumerthat takes whole batches implementsBatchConsumer; one that makes its own work implementsSelfDrivenConsumer.How it was tested
The alerting unit tests (60 classes, 472 tests), the alert integration tests (6 classes, 48 tests, including
AlertLedgerIT,AlertStateITandAlertTickOutcomesIT) and the existing alert integration tests (565 tests) pass on MySQL and on PostgreSQL.