Repository navigation
bug: Avoid 503 by not preloading all programs into the query-builder choices - #445
Open
TheWitness wants to merge 1 commit into
Open
TheWitness wants to merge 1 commit into
TheWitness wants to merge 1 commit into
Conversation
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change replacing unbounded program-choice preloading with bounded autocomplete.
No open issues 🎉
What changed in this PR
Reduces memory use in Syslog query-builder editors by removing the unbounded program-choice preload, addressing reported HTTP 503 errors on busy collectors.
Changes:
- Preloads only facility and priority choices; program fields use the existing bounded AJAX autocomplete.
- Updates regression assertions to confirm program choices are excluded.
- Documents the fix and affected editors in the changelog.
| File | Description |
|---|---|
| tests/Unit/SearchValuesTest.php | Confirms bounded choices remain populated and program choices are omitted. |
| includes/functions.php | Removes program preloading and documents the autocomplete fallback. |
| CHANGELOG.md | Records the memory-exhaustion fix under develop. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
syslog_search_choices()eagerly loaded every distinct program fromsyslog_programsto build theprogram_idquery-builder dropdown. On a busy collector that table can contain an effectively unbounded number of distinct program names, so the resulting choice array (and the JSON embedded into the page) could grow large enough to exhaust the PHPmemory_limitand fatal with an HTTP 503 when opening the Alert Rule, Removal Rule, and Dashboard editors. The Report Rule editor does not use the filter builder and therefore kept working, which matches the exact symptom reported on the forums.This change stops preloading programs. Only the small, fixed
facilityandpriorityenumerations are materialized as dropdown choices now. Theprogram/program_idfields already resolve through the bounded AJAX suggestion endpoint (syslog_search_suggestions(),LIMIT 30), so the builder transparently falls back to autocomplete for them with no UI loss — and gains it forprogram_id, which previously tried to render a full dropdown.Related Issue
Reported on the Cacti forums: https://forums.cacti.net/viewtopic.php?t=64912 — editing/creating Alert Rules, Removal Rules, and Dashboards returns
Fatal Error:503, while Report Rules work. The forum poster's MariaDB processlist pinpointed the slow, unbounded query:Motivation and Context
The 503 was a memory-exhaustion fatal, not a missing table/column. The query-builder's program dropdown is the only place that enumerated the entire
syslog_programstable on every editor render. Because programs are unbounded on active deployments, preloading them does not scale; autocomplete is the correct, already-present mechanism.How Has This Been Tested?
Ran the plugin's Pest suite against a Cacti checkout with the plugin at
plugins/syslog:Result: 644 passed (2683 assertions), with 1 pre-existing unrelated warning (
/proccmdline stub inProcessHelperCompatTest). TheSearchValuesTestregression test was updated to assert thatfacility_id/priority_idare preloaded whileprogram_idis intentionally not (it now uses bounded AJAX suggestions).Types of changes
Checklist: