Database Deadlock & Concurrency Race Condition Diagnosis
Diagnose Postgres/MySQL transaction deadlocks, lock contention, and concurrent update race conditions.
Analyze database deadlock graphs and transaction logs to identify lock acquisition ordering discrepancies and implement deterministic concurrency controls.
Execution Workflow Procedure
Ordered steps the coding agent executes when performing this skill.
Reconstruct Deadlock Graph
Parse the database engine deadlock log to map competing transactions, requested locks, and blocked processes.
Identify Resource Ordering Discrepancy
Determine why Transaction A acquired Lock 1 then requested Lock 2, while Transaction B did the inverse.
Implement Deterministic Locking
Enforce consistent primary key ordering in multi-row updates or introduce optimistic locking with version columns.
Agent Safety Guardrails & Anti-Hallucination Rules
- DO NOT recommend increasing lock timeouts as a substitute for fixing cyclic locking orders.
- DO NOT execute long-running transactions holding exclusive locks during peak traffic.
Expected Output Format
Lock acquisition sequence breakdown and refactored SQL/code.
Domain Verification Checks
Example Agent Invocations
Install / Configure This Skill
# Place in .cursorrules or create .cursor/rules/database-deadlock-concurrency-diagnosis.mdc # Trigger: Whenever you perform database deadlock & concurrency race condition diagnosis --- name: database-deadlock-concurrency-diagnosis description: Diagnose database deadlocks and lock contention to establish deterministic resource ordering and concurrency controls. version: 1.0.0 compatibility: [Cursor, Claude Code, Cline, Roo Code, Antigravity] --- # Database Deadlock & Concurrency Race Condition Diagnosis ## Objective Resolve database transaction deadlocks by analyzing lock graphs and establishing deterministic row lock acquisition orders. ## Workflow 1. **Lock Graph Analysis**: Parse deadlock logs to identify competing transactions and locked tuples. 2. **Order Discrepancy**: Identify where concurrent routines access rows in conflicting sequence. 3. **Deterministic Refactoring**: Sort IDs ascending before batch updates or apply optimistic locking with `@Version`.
Need a quick one-time prompt for chat?
Try the Database Deadlock & Concurrency Race Condition Investigator — a lightweight version designed for 1-click copying directly into Claude, ChatGPT, or Cursor chat.
SprintKit Workflow Integrations
Complementary tools and checklists to pair with this agent workflow.
Related Agent Skills
Explore related procedural workflows in this discipline.
Relational Database Schema Normalization & Indexing Strategy
Design production PostgreSQL schemas with composite indexes, foreign key strategies, and partitioning.
Production Exception & Stack Trace Root-Cause Analysis
Systematic investigation workflow for diagnosing production exceptions and constructing verified patches.
API Performance Bottleneck & N+1 Query Optimization
Diagnose slow database queries, serialization bottlenecks, and memory churn in sluggish API endpoints.