Skip to content

Vulnerability processing takes multiple hours at scale #31820

Closed

Description

@jahzielv

Fleet version: 4.71.1, but probably goes back a ways

Web browser and operating system: n/a


💥  Actual behavior

The "OVAL analyze" step in vulns processing is taking many hours.

Some output from a loadtest env:

{
  "cron": "vulnerabilities",
  "elapsed": "8h35m29.646716954s",
  "found new": 0,
  "level": "debug",
  "msg": "oval-analysis-done",
  "platform": "Ubuntu 22.04.1 LTS",
  "ts": "2025-08-12T10:41:08.827728475Z"
}

Env details:

  • 45k hosts, all Linux (Ubuntu 22.04)
  • 42k software
  • Default settings for Fleet server, RDS, and Redis
  • Note: no dedicated vulns processing job

🛠️ To fix

  • Investigate where in the processing job we could optimize code to get a speedup

Product designer: _________________________

🧑‍💻  Steps to reproduce

  1. Start a loadtest env as specified above
  2. Run vulns processing
  3. Note that the job takes hours to complete, if it completes at all

🕯️ More info (optional)

N/A

QA

Note: There is a non-deterministic CPE issue #39899 and another issue #39898 that may impact results.

Try in loadtest. And also:

Goal

Verify that the optimized branch produces identical CPE and CVE results as main.

Maybe @mostlikelee has a better QA flow, but this is what @getvictor did.

Steps

1. Create a test database clone
mysqldump --protocol=tcp -h 127.0.0.1 -P 3306 -u root -ptoor fleet > /tmp/fleet_dump.sql

mysql --protocol=tcp -h 127.0.0.1 -P 3306 -u root -ptoor -e "
  DROP DATABASE IF EXISTS fleet_vuln_test;
  CREATE DATABASE fleet_vuln_test;
  GRANT ALL ON fleet_vuln_test.* TO 'fleet'@'%';
"

mysql --protocol=tcp -h 127.0.0.1 -P 3306 -u root -ptoor fleet_vuln_test < /tmp/fleet_dump.sql
2. Clear vulnerability tables
mysql --protocol=tcp -h 127.0.0.1 -P 3306 -u fleet -pinsecure fleet_vuln_test -e "
  TRUNCATE software_cpe;
  TRUNCATE software_cve;
  TRUNCATE operating_system_vulnerabilities;
"
3. Build and run with main (baseline)
git worktree add /tmp/fleet-main main
cd /tmp/fleet-main && go build -o /tmp/fleet-main-bin ./cmd/fleet/
cd -

FLEET_MYSQL_DATABASE=fleet_vuln_test \
FLEET_VULNERABILITIES_DATABASES_PATH=/tmp/vulndbs \
FLEET_VULNERABILITIES_DISABLE_DATA_SYNC=true \
FLEET_LOGGING_TRACING_ENABLED=false \
FLEET_LOGGING_OTEL_LOGS_ENABLED=false \
  /tmp/fleet-main-bin vuln_processing --dev

This may take 30-60+ minutes on a large dataset.

4. Dump baseline results
mysql --protocol=tcp -h 127.0.0.1 -P 3306 -u fleet -pinsecure fleet_vuln_test \
  -e "SELECT software_id, cpe FROM software_cpe ORDER BY software_id, cpe" \
  > /tmp/baseline_cpe.tsv

mysql --protocol=tcp -h 127.0.0.1 -P 3306 -u fleet -pinsecure fleet_vuln_test \
  -e "SELECT software_id, cve, source, IFNULL(resolved_in_version,'') FROM software_cve ORDER BY software_id, cve, source" \
  > /tmp/baseline_cve.tsv

mysql --protocol=tcp -h 127.0.0.1 -P 3306 -u fleet -pinsecure fleet_vuln_test \
  -e "SELECT operating_system_id, cve, source FROM operating_system_vulnerabilities ORDER BY operating_system_id, cve, source" \
  > /tmp/baseline_os_vuln.tsv
5. Clear vulnerability tables again

Same as step 2.

6. Build and run with the branch (optimized)
# from the repo root on the feature branch
go build -o /tmp/fleet-branch-bin ./cmd/fleet/

FLEET_MYSQL_DATABASE=fleet_vuln_test \
FLEET_VULNERABILITIES_DATABASES_PATH=/tmp/vulndbs \
FLEET_VULNERABILITIES_DISABLE_DATA_SYNC=true \
FLEET_LOGGING_TRACING_ENABLED=false \
FLEET_LOGGING_OTEL_LOGS_ENABLED=false \
  /tmp/fleet-branch-bin vuln_processing --dev
7. Dump optimized results
mysql --protocol=tcp -h 127.0.0.1 -P 3306 -u fleet -pinsecure fleet_vuln_test \
  -e "SELECT software_id, cpe FROM software_cpe ORDER BY software_id, cpe" \
  > /tmp/optimized_cpe.tsv

mysql --protocol=tcp -h 127.0.0.1 -P 3306 -u fleet -pinsecure fleet_vuln_test \
  -e "SELECT software_id, cve, source, IFNULL(resolved_in_version,'') FROM software_cve ORDER BY software_id, cve, source" \
  > /tmp/optimized_cve.tsv

mysql --protocol=tcp -h 127.0.0.1 -P 3306 -u fleet -pinsecure fleet_vuln_test \
  -e "SELECT operating_system_id, cve, source FROM operating_system_vulnerabilities ORDER BY operating_system_id, cve, source" \
  > /tmp/optimized_os_vuln.tsv
8. Compare
diff /tmp/baseline_cpe.tsv /tmp/optimized_cpe.tsv
diff /tmp/baseline_cve.tsv /tmp/optimized_cve.tsv
diff /tmp/baseline_os_vuln.tsv /tmp/optimized_os_vuln.tsv

Activity

  1. added
    bug
    #g-auto-patching
    on Aug 12, 2025
  2. added
    :product
    and removed on Sep 22, 2025
  3. moved this from 📨 New requests to 🐥 Ready to estimate in 🦢📨🎉 Product design intake & outtakeon Sep 22, 2025
  4. added
    #g-supply-chain
    and removed
    #g-auto-patching
    on Sep 27, 2025
  5. getvictor commented on Oct 9, 2025

    @getvictor
    Member

    Timebox to 3. Hopefully, there is an obvious inefficiency.

  6. moved this from 🐥 Ready to estimate to 🦤 Estimated in 🦢📨🎉 Product design intake & outtakeon Oct 9, 2025
  7. getvictor commented on Oct 31, 2025

    @getvictor
    Member

    I've seen vulnerabilities job take over 11 hours, but it seemed due to infra issues, which eventually resolved themselves. From recent load test:

    MySQL [fleet]> select id, name, stats_type, status, created_at, updated_at from cron_stats where name = 'vulnerabilities' order by id desc;
    +-------+-----------------+------------+-----------+---------------------+---------------------+
    | id    | name            | stats_type | status    | created_at          | updated_at          |
    +-------+-----------------+------------+-----------+---------------------+---------------------+
    | 37095 | vulnerabilities | scheduled  | pending   | 2025-10-31 11:22:53 | 2025-10-31 11:22:53 |
    | 35543 | vulnerabilities | scheduled  | completed | 2025-10-31 09:22:53 | 2025-10-31 10:35:14 |
    | 33989 | vulnerabilities | scheduled  | completed | 2025-10-31 07:22:53 | 2025-10-31 08:34:39 |
    | 32452 | vulnerabilities | scheduled  | completed | 2025-10-31 05:22:53 | 2025-10-31 06:34:36 |
    | 30895 | vulnerabilities | scheduled  | completed | 2025-10-31 03:22:53 | 2025-10-31 04:34:35 |
    | 29350 | vulnerabilities | scheduled  | completed | 2025-10-31 01:22:53 | 2025-10-31 02:33:11 |
    | 27799 | vulnerabilities | scheduled  | completed | 2025-10-30 23:22:53 | 2025-10-31 00:31:42 |
    | 26243 | vulnerabilities | scheduled  | completed | 2025-10-30 21:22:53 | 2025-10-30 22:32:32 |
    | 16901 | vulnerabilities | scheduled  | completed | 2025-10-30 09:22:53 | 2025-10-30 21:07:27 |
    | 11524 | vulnerabilities | scheduled  | completed | 2025-10-30 02:22:53 | 2025-10-30 08:48:05 |
    |  6915 | vulnerabilities | scheduled  | completed | 2025-10-29 20:22:53 | 2025-10-30 01:56:51 |
    |  3074 | vulnerabilities | scheduled  | completed | 2025-10-29 15:22:53 | 2025-10-29 19:54:35 |
    |  1532 | vulnerabilities | scheduled  | completed | 2025-10-29 13:22:53 | 2025-10-29 15:15:30 |
    +-------+-----------------+------------+-----------+---------------------+---------------------+
    
  8. 14 remaining items

  9. linked a pull request that will close this issueVulnerabilities cron optimization #39820on Feb 14, 2026
  10. moved this from 🐣 In progress to 🦤 ‎In review in 🛡️ #g-supply-chainon Feb 16, 2026
  11. added and removed
    :product
    on Feb 16, 2026
  12. added a commit that references this issue on Feb 18, 2026
    092b51f
  13. moved this from 🦤 ‎In review to ✔️Awaiting QA in 🛡️ #g-supply-chainon Feb 18, 2026
  14. changed the title [-]Linux vulnerability processing takes multiple hours at scale[/-] [+]Vulnerability processing takes multiple hours at scale[/+] on Feb 19, 2026
  15. added
    :loadtest
    on Feb 25, 2026
  16. AndreyKizimenko commented on Mar 5, 2026

    @AndreyKizimenko
    Member

    QA notes

    Migration loadtest
    The first vuln run was scheduled on 4.81 the following ones were on 4.82
    4.82 is ~65% faster

    | id    | status    | created_at          | updated_at          | duration |
    | ----- | --------- | ------------------- | ------------------- | -------- |
    | 16739 | pending   | 2026-03-05 14:48:48 | 2026-03-05 14:48:48 | 00:00:00 |
    | 14647 | completed | 2026-03-05 11:48:48 | 2026-03-05 14:37:50 | 02:49:02 |
    | 11858 | completed | 2026-03-05 07:48:48 | 2026-03-05 11:35:34 | 03:46:46 |
    | 9069  | completed | 2026-03-05 03:48:48 | 2026-03-05 07:16:37 | 03:27:49 |
    | 4871  | expired   | 2026-03-04 21:48:48 | 2026-03-04 23:51:40 | 02:02:52 |
    | 681   | completed | 2026-03-04 15:48:48 | 2026-03-04 21:42:05 | 05:53:17 |
    

    Baseline loadtest

    | id    | status    | created_at          | updated_at          | duration |
    | ----- | --------- | ------------------- | ------------------- | -------- |
    | 14384 | pending   | 2026-03-10 15:39:50 | 2026-03-10 15:39:50 | 00:00:00 |
    | 11478 | completed | 2026-03-10 11:39:50 | 2026-03-10 15:13:29 | 03:33:39 |
    | 8553  | completed | 2026-03-10 07:39:50 | 2026-03-10 10:42:43 | 03:02:53 |
    | 5780  | completed | 2026-03-10 03:39:50 | 2026-03-10 06:39:55 | 03:00:05 |
    | 3604  | completed | 2026-03-10 00:39:50 | 2026-03-10 03:38:28 | 02:58:38 |
    | 701   | completed | 2026-03-09 20:39:50 | 2026-03-10 00:09:37 | 03:29:47 |
    
  17. moved this from ✔️Awaiting QA to ✅ Ready for release in 🛡️ #g-supply-chainon Mar 10, 2026
  18. moved this from ✅ Ready for release to Done in 🛡️ #g-supply-chainon Mar 12, 2026
  19. fleet-release commented on Mar 12, 2026

    @fleet-release
    Contributor

    Vuln processing slow,
    Optimized code, like wind flow,
    Hours to minutes grow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

#g-supply-chain:loadtestbug~old bug~software-ingestion~vulnerability-management

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions