-
Notifications
You must be signed in to change notification settings - Fork 699
Fixed MySQL deadlocks when multiple hosts are updating their certificates in host vitals at the same time. #34119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ates in host vitals at the same time.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
WalkthroughAddresses MySQL deadlocks when concurrently updating host certificate sources by enforcing deterministic processing and conditional deletions: sorts replacement sources to standardize lock order, deduplicates IDs for deletion, checks for existing rows before deleting, and performs insertions after deletion logic. No public APIs changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant S as Service
participant DS as Datastore
participant SQL as MySQL
S->>DS: Update host certificate sources
DS->>DS: Build toReplaceSources (inputs)
DS->>DS: Sort by (host_certificate_id, source, username)
DS->>DS: Deduplicate certificate IDs for deletion
DS->>SQL: SELECT EXISTS host_certificate_sources for IDs
alt Rows exist
DS->>SQL: DELETE FROM host_certificate_sources WHERE host_certificate_id IN (...)
else No rows
DS->>DS: Skip deletion
end
DS->>SQL: INSERT INTO host_certificate_sources (new rows)
DS-->>S: Return
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #34119 +/- ##
=======================================
Coverage 64.23% 64.23%
=======================================
Files 2058 2058
Lines 206902 206927 +25
Branches 6899 6899
=======================================
+ Hits 132900 132921 +21
- Misses 63576 63578 +2
- Partials 10426 10428 +2
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:
|
Related issue: Resolves #34116
Checklist for submitter
If some of the following don't apply, delete the relevant line.
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
Testing
Added/updated automated tests (see below)
QA'd all new/changed functionality manually
Local test that reproduces the issue and verifies fix. Not checked in.
Summary by CodeRabbit