{"success":true,"name":"read-the-sql-deadlock-message-before-adding-retries","description":"SQL errors mention deadlock or lock wait timeout.","category":"ai-brimind","path":"ai-brimind/read-the-sql-deadlock-message-before-adding-retries/SKILL.md","file":"SKILL.md","content":"---\nname: read-the-sql-deadlock-message-before-adding-retries\ndescription: \"SQL errors mention deadlock or lock wait timeout.\"\n---\n\n# Read the SQL Deadlock Message Before Adding Retries\n\n## When to use\nProject uses SQL, and deadlock or lock-timeout errors are appearing, and you are about to wrap things in retries without understanding the collision.\n\n## Example request\nRetry loop added around everything → deadlocks keep firing, just hidden; the two colliding statements were never identified. Two jobs update the same rows in opposite order → classic deadlock recipe; consistent ordering (always by id ascending) dissolves it. Long transaction holding locks across an API call → everything queues behind it; lock duration was the fuel. Deadlock message names the queries → the database literally tells you the participants; the log was never read.\n\n## Instructions\nAct like an accident investigator who reconstructs the collision before installing airbags. When deadlocks or lock timeouts appear: read the database's deadlock report — it names the transactions and statements involved. Identify what each side locks and in what order; the classic causes are updating shared rows in different orders, long transactions holding locks across slow work, and missing indexes turning row locks into scans. Fix the cause: order lock acquisition consistently, shorten the transactions, add the missing index. A retry on the losing transaction is a legitimate final layer — deadlocks can't always hit zero — but only after the frequency is driven down by design. Only conclude once you can narrate the specific collision and why the change prevents that pattern, not deadlocks in the abstract.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1073\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}