Skip to content

Backport to 4.83.0: Use swap table pattern and batch delete to improv…#42300

Merged
JordanMontgomery merged 1 commit intorc-minor-fleet-v4.83.0from
JM-41729
Mar 24, 2026
Merged

Backport to 4.83.0: Use swap table pattern and batch delete to improv…#42300
JordanMontgomery merged 1 commit intorc-minor-fleet-v4.83.0from
JM-41729

Conversation

@JordanMontgomery
Copy link
Copy Markdown
Member

…e DB access patterns for vuln cron (#41729)

Related issue: Resolves #41664

Switching kernel_host_counts to the established swap pattern. Reduce load on the DB writer by moving the large read to the DB reader.

Do CleanupSoftwareTitles in batches. With a single large select/delete, it took > 16 minutes. In batches, it took ~1.5 minutes in loadtest with 100K hosts.

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.

  • QA'd all new/changed functionality manually

For unreleased bug fixes in a release candidate, one of:

  • Alerted the release DRI if additional load testing is needed
  • Performance Improvements

  • Added indexing and a batched swap/insert flow to speed up vulnerability-related queries and lower maintenance contention.

  • Batched cleanup of orphaned records to reduce long-running delete operations.

  • Reliability

  • Migration removes a legacy constraint to simplify data maintenance and avoid migration failures.

  • Scheduled vulnerability refresh now runs more atomically to reduce disruption.

  • Tests

  • Updated assertion logic to improve test clarity for host-count verification.

…e DB access patterns for vuln cron (#41729)

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #41664

Switching `kernel_host_counts` to the established swap pattern. Reduce
load on the DB writer by moving the large read to the DB reader.

Do `CleanupSoftwareTitles` in batches. With a single large
select/delete, it took > 16 minutes. In batches, it took ~1.5 minutes in
loadtest with 100K hosts.

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.

- [x] QA'd all new/changed functionality manually

For unreleased bug fixes in a release candidate, one of:

- [x] Alerted the release DRI if additional load testing is needed

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

* **Performance Improvements**
* Added indexing and a batched swap/insert flow to speed up
vulnerability-related queries and lower maintenance contention.
* Batched cleanup of orphaned records to reduce long-running delete
operations.

* **Reliability**
* Migration removes a legacy constraint to simplify data maintenance and
avoid migration failures.
* Scheduled vulnerability refresh now runs more atomically to reduce
disruption.

* **Tests**
* Updated assertion logic to improve test clarity for host-count
verification.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@JordanMontgomery JordanMontgomery requested a review from a team as a code owner March 24, 2026 13:20
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

Tip: disable this comment in your organization's Code Review settings.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 70.08547% with 35 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (rc-minor-fleet-v4.83.0@26c1a97). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...atastore/mysql/operating_system_vulnerabilities.go 66.21% 16 Missing and 9 partials ⚠️
server/datastore/mysql/software.go 82.85% 3 Missing and 3 partials ⚠️
...s/20260316120000_DropKernelHostCountsForeignKey.go 50.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##             rc-minor-fleet-v4.83.0   #42300   +/-   ##
=========================================================
  Coverage                          ?   66.40%           
=========================================================
  Files                             ?     2503           
  Lines                             ?   200948           
  Branches                          ?     8872           
=========================================================
  Hits                              ?   133442           
  Misses                            ?    55441           
  Partials                          ?    12065           
Flag Coverage Δ
backend 68.17% <70.08%> (?)

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

☔ View full report in Codecov by Sentry.
📢 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.

@JordanMontgomery JordanMontgomery merged commit 6814004 into rc-minor-fleet-v4.83.0 Mar 24, 2026
41 of 45 checks passed
@JordanMontgomery JordanMontgomery deleted the JM-41729 branch March 24, 2026 13:50
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.

2 participants