Cherry-pick #52289: Fix software install status timeouts - #52619
Open
cdcme wants to merge 1 commit into
Open
Conversation
<!-- 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 -->
1 task
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Cherry-pick of #52289 into the 4.92.0 RC.
Testing