Commit graph

136 commits

Author SHA1 Message Date
Martin Angers
e65d6cfa06
Bugfix: don't show as available for install a software with an install request once host is moved/installer is deleted (#21064) 2024-08-06 12:31:01 -04:00
Martin Angers
ef07a406cc
Bugfix: list host software "Available for install" filter must show installers that have an install request on the host (#21083) 2024-08-06 10:14:01 -04:00
Victor Lyuboslavsky
580a81ded5
Fixed duplicate app install activity on host (#20944)
Unreleased bug for iOS/iPadOS VPP #19447

# Checklist for submitter
- [x] Added/updated tests
- [x] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [x] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [x] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [x] Manual QA for all new/changed functionality
2024-08-01 20:32:45 +02:00
Victor Lyuboslavsky
438b0ff4d6
Added available_for_install query parameter to host details (#20876)
Missing part of #19447
Added `available_for_install` query parameter to `GET
/api/v1/fleet/hosta/:id/software`

# Checklist for submitter

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-07-31 16:27:43 +02:00
Victor Lyuboslavsky
31224ccd34
Added VPP support for iOS/iPadOS (#20837)
#19447 
iOS and iPadOS apps can be installed using Apple's VPP (Volume Purchase
Program)

VPP apps are now using a composite primary key (Adam ID and platform)
because we want to keep iOS/iPadOS/macOS separate. It is possible for
one app to be installable on all Apple platforms.

# 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/Committing-Changes.md#changes-files)
for more information.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [x] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [x] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [x] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [x] Manual QA for all new/changed functionality
2024-07-30 22:43:51 +02:00
Tim Lee
0e9705fdf7
Add No Team to Software Backend (#20822) 2024-07-30 11:19:05 -06:00
Victor Lyuboslavsky
671fc628e7
Fetch installed apps from iPhone/iPad devices. (#20733)
Part 2 of https://github.com/fleetdm/fleet/issues/19447
- iOS and iPadOS user-installed apps are loaded into Fleet
- Added an additional identifier into software_titles table to
differentiate between iOS/iPadOS apps
- Updated nano queue timestamp precision

Note: TestIntegrationsMDM/TestVPPApps fails when run as part of the
suite, but passes standalone. I'd like to proceed with merging this PR,
and figure out the issue next week.

# Checklist for submitter

<!-- 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 support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Roberto Dip <rroperzh@gmail.com>
2024-07-28 16:17:27 +02:00
Jahziel Villasana-Espinoza
fda37851c1
fix: move last install data into apps and packages (#20664)
> Related issue: #20662

# 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] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-07-24 13:39:23 -04:00
Gabriel Hernandez
b5f64b7d95 Merge branch 'main' into feat-vpp-apps-18867 2024-07-19 14:33:56 +01:00
Martin Angers
b8b03b1e5a
VPP: update list software titles/list host's software response payloads (#20553)
#20536 

# Checklist for submitter

- [ ] 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.
- [ ] Added/updated tests

---------

Co-authored-by: Roberto Dip <rroperzh@gmail.com>
Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
2024-07-18 14:33:07 -07:00
Martin Angers
75bdc05f5d
VPP: unify List host's software and List my device's software response payload (#20519) 2024-07-16 16:52:04 -04:00
Martin Angers
0f9a549ed4
VPP: add VPP apps to list host's software endpoint (#20483) 2024-07-16 16:18:44 -04:00
Martin Angers
464c248f30
VPP: List/Get software title endpoints to return VPP apps (#20445) 2024-07-15 15:06:30 -04:00
Roberto Dip
a410f330b9
additional fix for loadtesting issues for bundle_identifier (#20377)
previous work at https://github.com/fleetdm/fleet/pull/20354
2024-07-11 14:33:20 -03:00
Roberto Dip
4d474a153c
separate queries for software matching to use indexes (#20354)
during load testing we found this query to be a bottleneck, locally
splitting in to two different statements makes a difference since we can
effectively use the indexes.

```
mysql> explain UPDATE software s
    -> JOIN software_titles st
    -> ON COALESCE(s.bundle_identifier, '') = '' AND s.name = st.name AND s.source = st.source AND s.browser = st.browser
    -> SET s.title_id = st.id
    -> WHERE (s.title_id IS NULL OR s.title_id != st.id)
    -> AND COALESCE(s.bundle_identifier, '') = '';
+----+-------------+-------+------------+-------+-------------------------------------------------------------------------------------+----------------------------+---------+------------------------------------------------+------+----------+-------------+
| id | select_type | table | partitions | type  | possible_keys                                                                       | key                        | key_len | ref                                            | rows | filtered | Extra       |
+----+-------------+-------+------------+-------+-------------------------------------------------------------------------------------+----------------------------+---------+------------------------------------------------+------+----------+-------------+
|  1 | SIMPLE      | st    | NULL       | index | idx_sw_titles                                                                       | idx_sw_titles              | 2302    | NULL                                           |  765 |   100.00 | Using index |
|  1 | UPDATE      | s     | NULL       | ref   | software_listing_idx,software_source_vendor_idx,title_id,idx_sw_name_source_browser | idx_sw_name_source_browser | 2302    | fleet.st.name,fleet.st.source,fleet.st.browser |    1 |    91.00 | Using where |
+----+-------------+-------+------------+-------+-------------------------------------------------------------------------------------+----------------------------+---------+------------------------------------------------+------+----------+-------------+
2 rows in set (0.00 sec)

mysql> explain UPDATE software s
    -> JOIN software_titles st
    -> ON s.bundle_identifier = st.bundle_identifier
    -> SET s.title_id = st.id
    -> WHERE s.title_id IS NULL
    -> OR s.title_id != st.id;
+----+-------------+-------+------------+------+-----------------------------------------------------+---------------------------------------+---------+---------------------------+------+----------+--------------------------+
| id | select_type | table | partitions | type | possible_keys                                       | key                                   | key_len | ref                       | rows | filtered | Extra                    |
+----+-------------+-------+------------+------+-----------------------------------------------------+---------------------------------------+---------+---------------------------+------+----------+--------------------------+
|  1 | UPDATE      | s     | NULL       | ALL  | title_id,idx_software_bundle_id                     | NULL                                  | NULL    | NULL                      |  788 |   100.00 | Using where              |
|  1 | SIMPLE      | st    | NULL       | ref  | idx_software_titles_bundle_identifier,idx_composite | idx_software_titles_bundle_identifier | 1023    | fleet.s.bundle_identifier |    1 |   100.00 | Using where; Using index |
+----+-------------+-------+------------+------+-----------------------------------------------------+---------------------------------------+---------+---------------------------+------+----------+--------------------------+
2 rows in set (0.00 sec)
```

# 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] Manual QA for all new/changed functionality
2024-07-10 18:16:38 -03:00
Tim Lee
2ea369c093
Custom Vulnerability Matching (#20118) 2024-07-09 11:50:22 -06:00
Tim Lee
812140a760
Add createdAt to Vulnerability responses (#20019) 2024-07-09 11:09:16 -06:00
Roberto Dip
e90b90d905
Match macOS software <-> titles using bundle identifier (#19969)
for #19144

# 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] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [x] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [x] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [x] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
2024-07-09 13:43:21 -03:00
Jahziel Villasana-Espinoza
57fa67c8c0
fix: filter by vulnerable software (#20241)
> Related issue: #20050

# 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] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-07-09 10:02:49 -04:00
Tim Lee
2d6458b3f8
Custom Ubuntu Kernel Vuln Scanning (#19588) 2024-06-17 15:44:01 -06:00
Roberto Dip
1cc13a09fb
🧹 friday cleanup party: substitute deprecated import of go-kit (#19774)
`go-kit/kit/log` was deprecated and generating warnings

# 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] Manual QA for all new/changed functionality
2024-06-17 10:27:31 -03:00
Victor Lyuboslavsky
8c4c739ef3
Display ingested software on host details page. (#19576)
#19348 

Fixed host details page and device details page not showing the latest
software.
- During software ingestion, software titles are now added if needed and
software items have their title_id field populated.
- In addition, after refreshing via UI, the software will be re-fetched
if it has been modified.

Added `exclude_software` query parameter to the
`/api/latest/fleet/hosts/:id` endpoint to exclude software from the
response.

PR for API doc change: #19617

Related issue filed for the Device User Page:
https://github.com/fleetdm/fleet/issues/19618

# 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-06-12 08:38:57 -05:00
Gabriel Hernandez
af88da49bc Merge branch 'main' into feat-software-self-service 2024-05-31 18:15:19 +01:00
Victor Lyuboslavsky
b3f0d07e51
Improved software ingestion performance by deduplicating incoming software. (#19325)
#11942 

To check if you have duplicate software, install multiple python
versions, like:
```shell
brew install python@3.11
brew install python@3.12
```

Then query: `SELECT * FROM python_packages` to see the packages with the
same versions but different paths.

# Checklist for submitter

- [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-30 13:14:49 -05:00
Martin Angers
6b9fecf172 Fix conflicts 2024-05-29 16:08:51 -04:00
Martin Angers
0b9b8c6279
Software SS: Add missing data to device software endpoints (#19304) 2024-05-29 08:54:48 -04:00
Martin Angers
16c4e0c411
Software SS: add self-service filter to list software titles and list host's/device's software (#19186) 2024-05-27 10:53:41 -04:00
Lucas Manuel Rodriguez
b7aac2cfab
Fix bundle_identifier for common software in osquery-perf (#19023)
bundle_identifier should be unique for the common software (should not
have hostname name in it).
2024-05-24 09:26:42 -03:00
Victor Lyuboslavsky
67ab732867
Optimizing MySQL master DB based on customer feedback (#19075)
#18838

1. During software ingestion, switched to updating `last_updated_at` as
a batch for 1 host.
2. Removed `DELETE FROM software` statement that ran for every host
update (where software was deleted). This is only done now during the
vulnerability job.

# 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-23 14:45:50 -05:00
Sarah Gillespie
8cc3d7dd4f
Update list host software to omit software installers for other platforms (#19088) 2024-05-16 17:09:41 -05:00
Roberto Dip
1ef19e4ff2 Merge remote-tracking branch 'origin/main' into feat-software-installers 2024-05-15 19:55:02 -03:00
Roberto Dip
d383876a3c
fix issues installing software in windows (#19048)
for #19039 and #19041 this:

- fixes the install/remove scripts to read the env variable the proper
way
- truncates output before storing in the databse in case its longer than
MySQL's TEXT size

# 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] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-05-15 19:39:42 -03:00
Victor Lyuboslavsky
825e785821
Optimizations to reduce MySQL writer DB load (#18880)
#18838 and #18986
Optimized master DB accesses during host software ingestion.

# 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-15 10:34:21 -05:00
Roberto Dip
da85d91551
add counts to host software endpoints (#18995)
part of #18677

# 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] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-05-15 09:55:27 -03:00
Martin Angers
3579e5a250
Software installers: backend cleanup tasks part 1 (#18955) 2024-05-14 08:37:07 -04:00
Victor Lyuboslavsky
abf4837eff
Broke apart the hourly host_software count query to reduce the individual query runtime (#18773)
#18221
Broke apart the hourly host_software count query to reduce the
individual query runtime. This fixes timeouts seen when host_software
table has over 25 million records.

I recommend hiding whitespace during review:
<img width="240" alt="image"
src="https://github.com/fleetdm/fleet/assets/2685025/6da9b643-8582-4d2f-bf32-8a1cc38f1032">


# Checklist for submitter

<!-- 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-08 09:27:17 -05:00
Martin Angers
7bb726ba8e
Create and return upcoming/past host activities for software installs (#18772) 2024-05-07 11:28:16 -04:00
Martin Angers
874c3cd811
Add orbit endpoint to receive results of a software installation attempt (#18689)
#18675
2024-05-03 13:03:59 -03:00
Sarah Gillespie
8f5b3a872d
Add backend to upload/delete software installers (#18660)
Issue #18320
2024-05-02 10:20:54 -03:00
Martin Angers
ad11f075c1
Add API endpoint to list host/device software (#18676) 2024-05-01 14:37:52 -04:00
Jacob Shandling
1cf7362968 Merge branch 'main' into 15919-vulnerabilities-page 2024-02-21 10:58:58 -08:00
Victor Lyuboslavsky
35ca4ee32b
Add team filter to software detail APIs (#16876)
#16787
2024-02-18 07:14:20 -06:00
Gabriel Hernandez
119d1df76f
add permission check to software titles/versions endpoints (#16561)
relates to #16052

This adds a team permission check the `GET software/titles/:id`
endpoint. If the user should not be able to get the software title if it
is not on a host that is on the same team as the user (e.g. software
title 1 is on host 1, which is on team 1. A user who is only on team 2
should get a 403 response)

The UI is also updated to show the access denied error page when the we
receive a 403 response for the software title

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

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
Co-authored-by: Roberto Dip <me@roperzh.com>
2024-02-15 17:22:27 -03:00
Roberto Dip
fbaa479d01
pre-calculate host counts for software titles (#15601)
found during the load test, this addresses a performance issue with
software titles.

# 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] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-13 12:48:57 -03:00
Martin Angers
3e4f36a20e
Add checksum hash unique column to software table. (#15598) 2023-12-12 17:51:58 -05:00
Roberto Dip
2ed3026819
Add pagination meta to software versions endpoint (#15550) 2023-12-12 12:24:20 -06:00
Sarah Gillespie
0e468b4981
Update software titles cron to include browser field (#15491) 2023-12-07 17:43:37 -06:00
Lucas Manuel Rodriguez
608038a1bb
Fix deadlock when deleting software during data ingestion (#15459)
This fixes the deadlock reported in #14779.

We found a deadlock in software ingestion during load tests performed in
October:
```
2023-10-26T17:20:41.719627Z 0 [Note] [MY-012468] [InnoDB] Transactions deadlock detected, dumping detailed information. (lock0lock.cc:6482)
2023-10-26T17:20:41.719661Z 0 [Note] [MY-012469] [InnoDB]  *** (1) TRANSACTION:  (lock0lock.cc:6496)
TRANSACTION 3069866646, ACTIVE 0 sec starting index read
mysql tables in use 2, locked 2
LOCK WAIT 8 lock struct(s), heap size 1136, 18 row lock(s), undo log entries 10
MySQL thread id 95, OS thread handle 70431326097136, query id 340045 10.12.3.105 fleet executing
DELETE FROM software WHERE id IN (165, 79, 344, 47, 212, 21, 60, 127, 173, 145) AND
        NOT EXISTS (
                SELECT 1 FROM host_software hsw WHERE hsw.software_id = software.id
        )
2023-10-26T17:20:41.719700Z 0 [Note] [MY-012469] [InnoDB]  *** (1) HOLDS THE LOCK(S):  (lock0lock.cc:6496)
RECORD LOCKS space id 932 page no 8 n bits 256 index PRIMARY of table `fleet`.`software` trx id 3069866646 lock_mode X locks rec but not gap
Record lock, heap no 22 PHYSICAL RECORD: n_fields 11; compact format; info bits 0
 0: len 8; hex 0000000000000015; asc         ;;
 1: len 6; hex 0000a74c4a7c; asc    LJ|;;
 2: len 7; hex 82000000d00264; asc       d;;
 3: len 26; hex 616e74692d76697275735f666f725f736f70686f735f686f6d65; asc anti-virus_for_sophos_home;;
 4: len 5; hex 322e322e36; asc 2.2.6;;
 5: len 4; hex 61707073; asc apps;;
 6: len 0; hex ; asc ;;
 7: len 0; hex ; asc ;;
 8: len 0; hex ; asc ;;
 9: len 0; hex ; asc ;;
 10: len 0; hex ; asc ;;

Record lock, heap no 48 PHYSICAL RECORD: n_fields 11; compact format; info bits 0
 0: len 8; hex 000000000000002f; asc        /;;
 1: len 6; hex 0000a74c4aad; asc    LJ ;;
 2: len 7; hex 81000000e30220; asc        ;;
 3: len 10; hex 7265616c706c61796572; asc realplayer;;
 4: len 11; hex 31322e302e312e31373338; asc 12.0.1.1738;;
 5: len 4; hex 61707073; asc apps;;
6: len 0; hex ; asc ;;
 7: len 0; hex ; asc ;;
 8: len 0; hex ; asc ;;
 9: len 0; hex ; asc ;;
 10: len 0; hex ; asc ;;

Record lock, heap no 61 PHYSICAL RECORD: n_fields 11; compact format; info bits 0
 0: len 8; hex 000000000000003c; asc        <;;
 1: len 6; hex 0000a74c4afb; asc    LJ ;;
 2: len 7; hex 820000017501ba; asc     u  ;;
 3: len 7; hex 636f6e6e656374; asc connect;;
 4: len 5; hex 332e322e37; asc 3.2.7;;
 5: len 4; hex 61707073; asc apps;;
 6: len 0; hex ; asc ;;
 7: len 0; hex ; asc ;;
 8: len 0; hex ; asc ;;
 9: len 0; hex ; asc ;;
 10: len 0; hex ; asc ;;

Record lock, heap no 80 PHYSICAL RECORD: n_fields 11; compact format; info bits 0
 0: len 8; hex 000000000000004f; asc        O;;
 1: len 6; hex 0000a74c4b32; asc    LK2;;
 2: len 7; hex 820000008a01cb; asc        ;;
 3: len 7; hex 68697063686174; asc hipchat;;
 4: len 4; hex 342e3330; asc 4.30;;
 5: len 4; hex 61707073; asc apps;;
 6: len 0; hex ; asc ;;
 7: len 0; hex ; asc ;;
 8: len 0; hex ; asc ;;
 9: len 0; hex ; asc ;;
 10: len 0; hex ; asc ;;

2023-10-26T17:20:41.720564Z 0 [Note] [MY-012469] [InnoDB]  *** (1) WAITING FOR THIS LOCK TO BE GRANTED:  (lock0lock.cc:6496)
RECORD LOCKS space id 695 page no 5994 n bits 1000 index host_software_software_id_fk of table `fleet`.`host_software` trx id 3069866646 lock mode S waiting
Record lock, heap no 31 PHYSICAL RECORD: n_fields 2; compact format; info bits 32
 0: len 8; hex 000000000000004f; asc        O;;
 1: len 4; hex 0000000c; asc     ;;

2023-10-26T17:20:41.720650Z 0 [Note] [MY-012469] [InnoDB]  *** (2) TRANSACTION:  (lock0lock.cc:6496)
TRANSACTION 3069866680, ACTIVE 0 sec starting index read
mysql tables in use 2, locked 2
LOCK WAIT 7 lock struct(s), heap size 1136, 12 row lock(s), undo log entries 8
MySQL thread id 98, OS thread handle 70375801900784, query id 340524 10.12.3.9 fleet executing
DELETE FROM software WHERE id IN (49, 113, 183, 187, 223, 79, 81, 116) AND
        NOT EXISTS (
                SELECT 1 FROM host_software hsw WHERE hsw.software_id = software.id
        )
2023-10-26T17:20:41.720682Z 0 [Note] [MY-012469] [InnoDB]  *** (2) HOLDS THE LOCK(S):  (lock0lock.cc:6496)
RECORD LOCKS space id 695 page no 5994 n bits 1000 index host_software_software_id_fk of table `fleet`.`host_software` trx id 3069866680 lock_mode X locks rec but not gap
Record lock, heap no 31 PHYSICAL RECORD: n_fields 2; compact format; info bits 32
 0: len 8; hex 000000000000004f; asc        O;;
 1: len 4; hex 0000000c; asc     ;;

2023-10-26T17:20:41.720760Z 0 [Note] [MY-012469] [InnoDB]  *** (2) WAITING FOR THIS LOCK TO BE GRANTED:  (lock0lock.cc:6496)
RECORD LOCKS space id 932 page no 8 n bits 256 index PRIMARY of table `fleet`.`software` trx id 3069866680 lock_mode X locks rec but not gap waiting
Record lock, heap no 80 PHYSICAL RECORD: n_fields 11; compact format; info bits 0
 0: len 8; hex 000000000000004f; asc        O;;
 1: len 6; hex 0000a74c4b32; asc    LK2;;
 2: len 7; hex 820000008a01cb; asc        ;;
 3: len 7; hex 68697063686174; asc hipchat;;
 4: len 4; hex 342e3330; asc 4.30;;
 5: len 4; hex 61707073; asc apps;;
 6: len 0; hex ; asc ;;
 7: len 0; hex ; asc ;;
 8: len 0; hex ; asc ;;
 9: len 0; hex ; asc ;;
 10: len 0; hex ; asc ;;

2023-10-26T17:20:41.720984Z 0 [Note] [MY-012469] [InnoDB] *** WE ROLL BACK TRANSACTION (2)  (lock0lock.cc:6496)
```

I was able to reproduce this issue on `main` with the added test. The
solution is to remove the deletion (cleanup) of `software` to a separate
transaction after the main transaction is done.

- [X] Changes file added for user-visible changes in `changes/` or
`orbit/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
2023-12-07 09:34:53 -03:00
Sarah Gillespie
f19dc8abe0
Add GET software/versions and GET software/versions/:id endpoints (#15450) 2023-12-06 08:30:49 -06:00
Sarah Gillespie
0db59a7a25
Add cron for software titles feature (#15422) 2023-12-04 10:09:23 -06:00