Batch select query in CleanupExcessQueryResultRows - #40491
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #40491 +/- ##
=======================================
Coverage 66.26% 66.27%
=======================================
Files 2461 2461
Lines 197427 197434 +7
Branches 8655 8655
=======================================
+ Hits 130832 130847 +15
+ Misses 54749 54745 -4
+ Partials 11846 11842 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
sgress454
left a comment
There was a problem hiding this comment.
This looks good but I think the bigger fix is to update the SQL for the initial QueryIDs statement here to include saved=1 in the WHERE clause. Live reports don't save rows in the query_results table anyway so there's nothing to clean up for them, and we're wasting cycles fetching them.
Your added batching is still a good idea, just in case a customer really does have >65k saved reports, but it should rarely be used if we fix the filtering.
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #40476 # 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-changes.md#changes-files) for more information. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually Before: - inserted 70k queries to my local DB, saw the cron failing: <img width="864" height="120" alt="Screenshot 2026-02-25 at 12 54 31 PM" src="https://github.com/user-attachments/assets/d1e19aa8-56aa-46a2-a437-7ae5da1e5b1e" /> - ran new test without code fix, it failed with the same error in the issue: <img width="920" height="324" alt="Screenshot 2026-02-25 at 12 45 41 PM" src="https://github.com/user-attachments/assets/c7342d81-f223-449e-a861-c7bae58bbe9e" /> After: ran test again, it passed <img width="1556" height="174" alt="Screenshot 2026-02-25 at 12 45 04 PM" src="https://github.com/user-attachments/assets/9eed3e6e-3ce6-4d69-aa70-9ebcfcf07623" />
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #40476 # 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-changes.md#changes-files) for more information. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually Before: - inserted 70k queries to my local DB, saw the cron failing: <img width="864" height="120" alt="Screenshot 2026-02-25 at 12 54 31 PM" src="https://github.com/user-attachments/assets/d1e19aa8-56aa-46a2-a437-7ae5da1e5b1e" /> - ran new test without code fix, it failed with the same error in the issue: <img width="920" height="324" alt="Screenshot 2026-02-25 at 12 45 41 PM" src="https://github.com/user-attachments/assets/c7342d81-f223-449e-a861-c7bae58bbe9e" /> After: ran test again, it passed <img width="1556" height="174" alt="Screenshot 2026-02-25 at 12 45 04 PM" src="https://github.com/user-attachments/assets/9eed3e6e-3ce6-4d69-aa70-9ebcfcf07623" />
- **Batch select query in CleanupExcessQueryResultRows (#40491)** - **Cherry-pick: Remove "do not enqueue setup experience items >24 hours after enrollment" logic for macOS hosts (#40739) (#40748)** --------- Co-authored-by: Nico <32375741+nulmete@users.noreply.github.com> Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com> Co-authored-by: Jordan Montgomery <elijah.jordan.montgomery@gmail.com>
Related issue: Resolves #40476
Checklist for submitter
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
Testing
Added/updated automated tests
QA'd all new/changed functionality manually
Before:
After: ran test again, it passed