Skip to content

Cherry-pick #52289: Fix software install status timeouts - #52619

Open
cdcme wants to merge 1 commit into
rc-minor-fleet-v4.92.0from
cp-52289-fix-software-install-status-timeouts
Open

Cherry-pick #52289: Fix software install status timeouts#52619
cdcme wants to merge 1 commit into
rc-minor-fleet-v4.92.0from
cp-52289-fix-software-install-status-timeouts

Conversation

@cdcme

@cdcme cdcme commented Sep 4, 2026

Copy link
Copy Markdown
Member

Cherry-pick of #52289 into the 4.92.0 RC.

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #51426. Also fixes #51563, the same defect
in `GetSummaryHostVPPAppInstalls`.

These queries pick the most recent activity per host twice: once over
the pending queue, once over the completed install history. #47949
rewrote only the queue half. This applies the same `ROW_NUMBER()`
rewrite to the history half at the six remaining fleet-wide sites.

The rewrite is output-identical by construction. `(created_at, id)` is a
total order, so exactly one row per host already survived. `status`, the
queue check, and the VPP `nano_command_results` guard all stay after `rn
= 1`. Folding any of them into the ranking would pick a different row.

| 2,000 hosts, 60 installs each | Rows read | Wall clock |
|---|---|---|
| `GET /software/titles/:id` | 3,780,000 to 120,000 | 3.98 s to 0.15 s |
| `GET /hosts/count?…&software_status=installed` | 3,780,656 to 120,000
| 4.74 s to 0.15 s |

Ranking now runs before the status filter, so one case costs more. A
status that matches no hosts goes from 0.54 s to 0.76 s. A status that
matches every host goes from 10.2 s to 0.64 s.

# Checklist for submitter

- [x] Changes file added for user-visible changes in `changes/`.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in 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

`testInstallStatusUsesLatestRowPerHost` pins row selection. The newest
row wins over an older success. Canceled and removed rows fall back to
the previous row. A `created_at` tie breaks by `id`, and a queued
install supersedes history. It passes on `main` too.
`testInstallStatusDoesNotScanHistoryPerHostRow` bounds rows touched, and
fails on `main`.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Fixed timeouts on software title details pages and the hosts list
software status filter when processing software with extensive
installation history.
* Improved accuracy when determining each host’s latest software
installation status.
* Reduced repeated processing of installation history, improving
performance for large datasets.


<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@cdcme
cdcme requested a review from a team as a code owner September 4, 2026 21:14
@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (rc-minor-fleet-v4.92.0@21f770a). Learn more about missing BASE report.

Additional details and impacted files
@@                    Coverage Diff                    @@
##             rc-minor-fleet-v4.92.0   #52619   +/-   ##
=========================================================
  Coverage                          ?   69.80%           
=========================================================
  Files                             ?     4072           
  Lines                             ?   265590           
  Branches                          ?    14064           
=========================================================
  Hits                              ?   185397           
  Misses                            ?    63991           
  Partials                          ?    16202           
Flag Coverage Δ
backend 70.27% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Software title detail page returns 500 errors when install activity queue is large

1 participant