fleet/changes
Victor Lyuboslavsky 9c714c544d
Optimized policy_stats updates to NOT lock the policy_membership table (#18720)
#16562

Optimized policy_stats updates to NOT lock the policy_membership table.
This should improve deployment performance with many global policies and
team hosts.

The original implementation that used INSERT ... SELECT (SELECT
COUNT(*)) ... caused performance issues. Given 50 global policies, 10
teams, and 10,000 hosts per team, the INSERT query took 30-60 seconds to
complete. Since it was an INSERT query, it blocked other hosts from
updating their policy results in policy_membership.

Now, we separate the INSERT from the SELECT, since SELECT by itself does
not block other hosts from updating their policy results. In addition,
we process one global policy at a time, which reduces the time to
complete the SELECT query to <2 seconds, and limits the memory usage. We
are not using a transaction to reduce locks. This means that INSERT may
fail if the policy was deleted by a parallel process. Also, the INSERT
may overwrite a clearing of the stats. This is acceptable, since these
are very rare cases. We log and proceed in that case.


# Checklist for submitter

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

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-05-06 09:48:37 -05:00
..
.keep Issue 1009 calculate diff software (#1305) 2021-07-08 13:57:43 -03:00
16562-deadlock Updated host_operating_system INSERT. (#18556) 2024-04-29 10:54:50 -05:00
16562-policy_stats-lock Optimized policy_stats updates to NOT lock the policy_membership table (#18720) 2024-05-06 09:48:37 -05:00
16989-delete-activities Delete expired activities in cleanup cron (#18441) 2024-04-26 07:22:31 -03:00
16989-ui-to-delete-old-activities Fleet UI: Activity log expiry settings (#18243) 2024-04-26 15:14:49 -04:00
17110-win-os-reporting Update Windows OS Version Reporting (#17682) 2024-05-01 12:02:16 -06:00
17321-zsh-support Zsh script support (#18411) 2024-04-30 14:38:56 -04:00
17360-better-url-email-validators Frontend: Improve URL and email validation (#18445) 2024-04-25 13:03:30 -04:00
17771-invalid-query-platforms UI – render informative message when user tries to save query with invalid platform(s) (#18473) 2024-04-24 15:25:33 -07:00
18039-private-IPv6-address Fixed ingestion of private IPv6 address from agent. (#18738) 2024-05-03 15:07:09 -05:00
18079-query-results-bug-transfer-hosts Cleanup query results after host is transferred to another team (#18712) 2024-05-03 17:37:55 -03:00
18085-fix-repeated-install-commands-of-fleetd-on-windows-mdm Fix sending of "install Fleetd" commands repeatedly on Azure-enrolled Windows devices (#18453) 2024-04-29 08:48:54 -04:00
18157-update-platform-policy-stats When updating a policy's 'platform' field, the aggregated policy stats are now cleared. (#18415) 2024-04-29 10:20:59 -05:00
18173-linux-async-wipe Linux Wipe Async (#18372) 2024-04-29 09:55:05 -04:00
18187-ai-generated-backend AI-generated calendar backend changes (#18571) 2024-05-02 11:56:54 -05:00
18394-print-team-id fleetctl get teams prints team id (#18395) 2024-04-29 09:56:04 -04:00
18424-fix-users-query-for-linux Fix users query for linux devices (#18454) 2024-04-26 15:05:34 -03:00
18558-windows-mdm-start fixed a bug causing servers with Windows MDM only to crash (#18568) 2024-04-26 10:09:01 -05:00
18597-missing-tooltips UI –Restore missing tooltips (#18598) 2024-04-29 10:48:35 -04:00
18601-add-ubuntu-oval 18601 add ubuntu sources (#18602) 2024-05-02 13:20:00 -06:00
18605-host-expiry-window-setting Fleet UI fix: Input is treated as strings but send number to API (#18652) 2024-05-01 09:17:08 -04:00
18640-gitops-remove-teams GitOps remove teams (#18640) 2024-05-03 08:03:00 -05:00
hosts-lifecycle add consistent MDM host lifecycle management (#18510) 2024-04-29 16:43:15 -03:00
issue-18389-fix-uploading-signed-apple-mobileconfig-profiles Fix uploading signed apple mobileconfig profiles (#18482) 2024-04-25 17:09:53 +01:00