fix: Preserve admin segment lock order during discovery#3265
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Summary by CodeRabbit
Walkthrough
ChangesDPU Segment Locking
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant discover_machine
participant machine_interface
participant Database
Client->>discover_machine: discover_machine(hardware_info)
discover_machine->>Database: begin txn
alt hardware_info.is_dpu()
discover_machine->>machine_interface: load_and_lock_all_admin_segments(&mut txn)
machine_interface->>Database: lock admin segments
end
discover_machine->>Database: continue discovery updates
discover_machine-->>Client: discovery completes
sequenceDiagram
participant Test
participant set_primary_interface_core
participant machine_interface
participant PostgreSQL
Test->>PostgreSQL: open blocker txn and hold admin segment locks
Test->>set_primary_interface_core: set_primary_interface(...)
set_primary_interface_core->>machine_interface: load_and_lock_all_admin_segments(&mut txn)
machine_interface->>PostgreSQL: wait on admin segment locks
Test->>PostgreSQL: verify target row is not locked early
Test->>PostgreSQL: release blocker txn
set_primary_interface_core-->>Test: primary-interface repair completes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2fcc29b830
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🔍 Container Scan Summary
Per-CVE detail lives in the per-service |
Summary
Prevent a PostgreSQL deadlock in DPU discovery by making the discovery transaction acquire admin-network-segment advisory locks before it updates or locks machine-interface rows. Address allocation already uses this segment-lock-before-row-lock order.
Root cause
The 18-tray machine-a-tron lifecycle in #3207 exposed a pre-existing lock inversion:
PostgreSQL repeatedly reported
deadlock detectedfrom theFOR UPDATE OF miquery inreconcile_admin_addresses_for_host, paired with another transaction waiting onpg_advisory_xact_lock.Fix
The DPU discovery transaction now calls the existing
load_and_lock_all_admin_segmentshelper before any machine-interface work. The helper is made public within the database crate so both paths use the same lock order.No new locking primitive, abstraction, or dependency is introduced.
Before and after evidence
Removing only this two-file change reproduced repeated deadlocks in the 18-tray lifecycle. Restoring it made the same rack-scale path complete in 83.85 seconds:
The passing run contained no
deadlock detectedentry.Verification
Hotfix revision:
2fcc29b83052d745d2fb39374cc2e812c342cd5bBase revision: upstream
mainatb7154872bSupporting checks passed:
Hands-on regression exercise:
The focused lifecycle test currently lives in #3207. Its copy of this two-file fix has the same stable Git patch ID as this hotfix:
76226037bcbdaef26b31592f98bb7f3e6c1d8741.The direct
carbide-api-coreunit-test target cannot build on this Apple Silicon host because its circular test-harness dev dependency re-enables the Linux-only default TPM feature. The no-default-features library check verifies the hotfix build without that unsupported target; the real PostgreSQL lifecycle above exercises the changed lock path.Relationship to #3207
#3207 exposed the deadlock but does not own the production lock-order behavior. This hotfix is separate so the concurrency fix has a focused review, merge, and rollback path. #3207 remains draft and depends on this PR merging first.
Risk and scope