Skip to content

Cap admin dashboard pending/scheduled details to avoid OOM on backlogs#497

Merged
dereuromark merged 2 commits into
masterfrom
admin-dashboard-limit-pending-details
May 13, 2026
Merged

Cap admin dashboard pending/scheduled details to avoid OOM on backlogs#497
dereuromark merged 2 commits into
masterfrom
admin-dashboard-limit-pending-details

Conversation

@dereuromark
Copy link
Copy Markdown
Owner

Problem

QueueController::index() unconditionally materialises every pending and every scheduled queued_jobs row, then passes both arrays to the view. With a realistic backlog (thousands of pending or failed-and-retried jobs) two things go wrong:

  • the rendered Bootstrap-card table grows linearly with rows and is heavy per row
  • DebugKit's Variables panel serialises every view variable and can blow past memory_limit (saw a 175MB allocation attempt at 10k rows)

Fix

  • Cap visible pending/scheduled lists at Queue.adminDetailsLimit (default 200). New config key documented in config/app.example.php.
  • Detect truncation with a +1 row probe so we avoid a second count() query on small queues.
  • Aggregate tile counts ("new", "pending", "scheduled") computed via DB count() against the same conditions so they keep reflecting the true totals regardless of the visible-list cap.
  • New companion getters on QueuedJobsTable: getPendingCount(), getScheduledCount(), getNewCount(). Pair with the existing getPendingStats() / getScheduledStats() SelectQuery getters.
  • Template renders a "Showing N most recent of M" notice when a list is truncated, with a pre-filtered link to the QueuedJobs admin (?status=in_progress for pending, ?status=scheduled for scheduled) so the admin lands on exactly the rows the truncated list represents.

Tests

  • testIndexTruncatesPendingDetailsAtDetailsLimit — sets the cap to 3, queues 5 jobs, asserts the truncation flag plus the true total.
  • testIndexNotTruncatedWhenWithinLimit — single job, asserts truncation flags stay false (avoids the extra count() query in the common case).

Both branches green: 16 tests / 40 assertions.

The admin index unconditionally materialised every pending and every
scheduled queued_jobs row, then passed both arrays to the view. With a
realistic backlog (thousands of unfetched pending jobs) the response
balloons in two ways:

 - the rendered table HTML grows linearly with rows (the modern
   Bootstrap dashboard is heavier per row than the pre-overhaul one),
 - DebugKit's Variables panel serialises every view variable and can
   blow past memory_limit while building its snapshot.

Fix: cap the visible pending/scheduled lists at Queue.adminDetailsLimit
(default 200), detect truncation with a +1 row probe so we avoid a
second count() on small queues, and compute the "new" / pendingJobs /
scheduledJobs tile counts via DB count() queries against the same
conditions so the tiles still reflect the true totals.

Adds QueuedJobsTable::getPendingCount() / getScheduledCount() /
getNewCount() to keep the count-query conditions next to the matching
SelectQuery getters.

Template renders a "Showing N most recent of M" notice when a list
was truncated, with a link to the QueuedJobs admin for the full view.

Documents Queue.adminDetailsLimit in config/app.example.php.

Tests cover both the truncated and within-limit paths.
When the dashboard caps the pending/scheduled lists, the 'See QueuedJobs
admin' link from the truncation banners now carries ?status=in_progress
(pending) or ?status=scheduled, matching the existing search-collection
filter names. Lands you exactly on the rows the truncated list
represents instead of the full mixed list of completed + failed +
running entries.
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 82.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.38%. Comparing base (06c5d48) to head (3ba163d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/Model/Table/QueuedJobsTable.php 75.86% 7 Missing ⚠️
src/Controller/Admin/QueueController.php 90.47% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #497      +/-   ##
============================================
+ Coverage     77.55%   78.38%   +0.82%     
- Complexity      972     1007      +35     
============================================
  Files            45       45              
  Lines          3262     3415     +153     
============================================
+ Hits           2530     2677     +147     
- Misses          732      738       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dereuromark dereuromark merged commit c575000 into master May 13, 2026
16 checks passed
@dereuromark dereuromark deleted the admin-dashboard-limit-pending-details branch May 13, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants