Repository navigation
fix(alerts): bound the work of each alert request and tick (backport 2.1 #36279) - #36343
Conversation
…ot per destination
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
| .withRelevantUnprocessedEventsList( | ||
| listCountOnly ? null : relevantUnread(progress, limit, paginationOffset)) | ||
| .withTotalUnprocessedEventsList( | ||
| listCountOnly ? null : progress.allUnread(limit, paginationOffset)); |
There was a problem hiding this comment.
Diagnostics still loads huge events
diagnosticInfo still loads and returns each unread event's full entity. Both lists use listUnprocessedEvents, which has neither the new byte budget nor entity removal. A request with limit=1000 over 5 MB events can therefore load gigabytes twice, despite this PR's listing bounds.
Use a byte-bounded read for rule evaluation, then remove entity before returning either list. Extend the no-entity test to both diagnostics routes.
| } catch (RejectedExecutionException e) { | ||
| throw new WebApplicationException( | ||
| "Too many alert counts are running; try again shortly", | ||
| e, | ||
| Response.Status.TOO_MANY_REQUESTS); |
There was a problem hiding this comment.
When the count workers and queue are full, PendingCounts throws a 429. All four eventsRecord and diagnosticInfo routes catch it as Exception and return 500 instead. API clients never receive the new response telling them to try later.
Preserve WebApplicationException before the generic catch in these routes.
| private final Map<String, EntityFixtureBuilder> builders = new ConcurrentHashMap<>(); | ||
| private final Map<Scenario, EntityFixtureEventApplier> appliers = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
builders and appliers still have no size cap after the switch to ConcurrentHashMap. Both retain entries through computeIfAbsent, including entries for arbitrary resource names. This violates the repository directive that all caches must have an explicit size cap.
Use bounded caches, such as Caffeine with maximumSize, while keeping concurrent access safe. This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
…yped errors from alert status routes
Code Review ✅ Approved 1 closed / 1 findings🔴 High risk · Removing embedded entity data from alert event listings could break API clients that depend on those response fields. Bounds alert request and tick work with fixed limits on batch size, destinations, receivers, event reads, pending counts, test sends, HTTP exchanges, chat rendering, and mail queues, addressing the unbounded template preview fixture cache. No open issues remain. ✅ 1 closed✅ Bug: Fixture registry caches grow without bound on user-chosen resource names
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
|



Backport of PR #36279 to the 2.1 release branch. The branch was cut from main with no other changes, so the commits apply unchanged.
What was wrong
Alerting work grew without limit with what an alert held, a request asked for, or a user wrote, so one request or tick could fill the heap or hold threads forever:
batchSizewent straight to SQL, every change event embeds its whole entity, and the eight alert event listings had no row limit.eventsRecordanddiagnosticInfoevaluated every unread event on each view.batchSize, destinations and receivers had no upper bound; saving compared destinations in quadratic time.Error(for exampleOutOfMemoryError) was retried forever instead of being set aside.What this changes
Each path gets one fixed bound, recorded in
ADR:2026-10-26-alerting-bounds-the-work-of-each-request-and-tick:batchSizeentityAlso:
Errorkeeps its "in progress" note, so the existing set-aside after six attempts applies.What users see
entity.Before merging
Please check the bounds against real data: no stored alert should be near 1000 for
batchSize, 50 destinations or 100 receivers.Tests
Every new test failed on main first: for example, 500 nested quotes rendered 8,007,000 characters, three 5 MB events were read in one tick, and a test send to 51 destinations was accepted.
The decision record's
Guardline lists the tests.Passing: all 16 alert integration test classes on MySQL and Postgres (584 each) before the final receiver changes; after them, 614 unit tests and the affected integration tests (283) on MySQL.
The PR should not merge until diagnostic reads are bounded, count overload preserves 429 responses, and preview caches meet the required size cap.
Findings
Summary
This backport adds fixed limits to alert reads, counts, rendering, test sends, HTTP exchanges, and mail queues.
Since the previous review:
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR Request[Alert request] --> Limits[Check configured limits] Limits --> Counts[Bounded pending count] Limits --> Sends[Concurrent test sends] Sends --> Render[Chat render budget] Render --> HTTP[HTTP deadline and response cap] Tick[Alert tick] --> Read[Row and byte bounded read] Read --> Deliver[Evaluate and deliver] Deliver --> Commit[Save progress and outcomes]Reviews (4) · Last reviewed commit: "fix(alerts): make the template preview f..." · Reviewed by Greptile