Repository navigation
Fixes #34204, #34205: stop event consumers idling after a slow batch, and give fresh reads their own cache - #34209
Conversation
Code Review ✅ Approved🟡 Medium risk · Scheduler misfire timing and scoped entity caching alter backend execution behavior. Fixes event consumer stall and fresh-read cache issues by running late consumers immediately with a 5-second misfire check instead of waiting up to 60 seconds, and giving each fresh-read scope its own request cache so workflows don't rebuild the same entities repeatedly. Approval tasks, workflow status changes, and alert deliveries will no longer lag by minutes under load. No issues found. 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 |
🚦 Removed from the merge queue —
|
Problem
Tests that wait for a governance approval task time out on the MySQL lane, and real servers under load see the same delay: approval tasks and alert deliveries arrive minutes late.
Why it happened
Two things add up. First, every change event consumer is a repeating Quartz trigger in the clustered database job store. Quartz plans each next run from the previous planned time, so runs longer than the interval push the trigger further behind. After 60 seconds behind, normal scheduling skips it and only a check that runs every 60 seconds picks it up again, so a busy consumer sat idle up to a minute, every two minutes. Second, inside a fresh-read scope the per-request entity cache was switched off entirely, and every governance workflow runs inside one. Each workflow step then rebuilt the same entity from the database (three times for a new metric, about six with reviewers), which made workflow events 20 to 50% slower and the stall far more frequent.
What this PR changes
What users will notice
Approval tasks, workflow status changes and alert deliveries no longer lag by minutes when many entities change at once. Existing servers pick up the new schedule on their next restart.
How it was tested
New unit tests pin the scheduler settings (5 second misfire check, the "run now" policy on both polling triggers, and a trigger stored by an older version being rewritten on restart) and the scope rules (no earlier entries visible, repeated reads served from the scope, invalidation reaching every open scope, nothing surviving it). With the old code back, 6 scheduler tests and 5 cache tests fail; the tests that guard the alert scheduler fix pass both ways. 739 unit tests across the affected packages pass. A standalone Quartz reproduction with our settings: before, 20 seconds idle after a slow run; after, the next run starts within 0.1 seconds. This PR's integration lanes run the subscription scheduling, governance approval and cache suites; their approval-test durations and consumer pauses are compared with main.
Not in this PR
The 2.0 backport of the scheduler change (separate PR). A redesign of how consumers are scheduled and how workflows read entities is tracked separately.
Fixes #34204
Fixes #34205