**Related issue:** Resolves #47839 The software title details page (`GET /api/v1/fleet/software/titles/{id}`) could take minutes to load and return a 500 or 502 when an installer, VPP app, or in-house app was scoped to many hosts. The cause was the status summary query. To find each host's most recent pending activity, it joined `upcoming_activities` to itself, and an `OR` in the join condition stopped MySQL from using an index. The query got much slower as the pending backlog grew. This rewrites the query in all three summary functions (`GetSummaryHostSoftwareInstalls`, `GetSummaryHostVPPAppInstalls`, `GetSummaryHostInHouseAppInstalls`) to use a `ROW_NUMBER()` window function. It filters to the installer or app first, then picks each host's most recent activity, which removes the self-join. It also fixes a related bug where the old `OR` condition could drop a host from the counts. Verified live against a 6,000-host backlog. The page went from ~12.7s to ~1.1s with identical status counts. # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-chan ges.md#changes-files) for more information. - [x] `SELECT *` is avoided and SQL injection is prevented (named placeholders used for all values in the modified statements). ## Testing - [x] Added/updated automated tests - [x] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [x] QA'd all new/changed functionality manually ## Before (reproduction): [before.webm](https://github.com/user-attachments/assets/f03154d5-6062-42e3-81d3-ce33b0809145) ## After (fix): [after.webm](https://github.com/user-attachments/assets/b6d1ce53-7778-4023-84b7-56c49d846649) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed software title details pages timing out for installers, VPP apps, and in-house apps when hosts have large backlogs of pending activities. * Improved pending software install status selection to prevent hosts from being dropped or counted inconsistently when multiple upcoming activities exist. * **Tests** * Added regression coverage for upcoming-per-host counting without dropouts when multiple queued activity entries share the same host and app context. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 lines
141 B
Plaintext
2 lines
141 B
Plaintext
- Fixed software title details pages timing out for installers, VPP apps, and in-house apps with a large backlog of pending host activities.
|