diag-mysql-deadlock

diag-mysql-deadlock is a skill for Claude Code, Codex from seed-forge/harness-ai-kit. It costs 99 tokens per session (1,806 once invoked), scanned A, original, Apache-2.0.

A diagnostic runbook for MySQL deadlocks, where database transactions block one another in a cycle and cannot all continue. It examines InnoDB locks, waiting transactions, long transactions, and common locking patterns.

In plain words
What is it for?
Use it when applications report deadlock errors, deadlock counters increase, or peak traffic causes lock contention. It produces a structured analysis with SQL, code, and configuration repair suggestions.
Why use it?
It helps show which transaction holds each lock and which transaction is waiting, instead of relying on a generic deadlock error. It supports MySQL 5.6 and newer with newer or fallback metadata sources.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when applications report deadlock errors, deadlock counters increase, or peak traffic causes lock contention. It produces a structured analysis with SQL, code, and configuration repair suggestions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/seed-forge/harness-ai-kit/diag-mysql-deadlock
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add seed-forge/harness-ai-kit --skill diag-mysql-deadlock
Clone the repo
git clone --depth 1 https://github.com/seed-forge/harness-ai-kit

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for diag-mysql-deadlock

README.md
[![agentmods](https://agentmods.dev/badge/skills/seed-forge/harness-ai-kit/diag-mysql-deadlock/github.svg)](https://agentmods.dev/skills/seed-forge/harness-ai-kit/diag-mysql-deadlock)
Your own site
<a href="https://agentmods.dev/skills/seed-forge/harness-ai-kit/diag-mysql-deadlock"><img src="https://agentmods.dev/badge/skills/seed-forge/harness-ai-kit/diag-mysql-deadlock/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for diag-mysql-deadlock

Your own site · 80×15
<a href="https://agentmods.dev/skills/seed-forge/harness-ai-kit/diag-mysql-deadlock"><img src="https://agentmods.dev/badge/skills/seed-forge/harness-ai-kit/diag-mysql-deadlock.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 99 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,806 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00099 $0.01806
Opus 5 $0.00049 $0.00903
Sonnet 5 $0.00020 $0.00361
Haiku 4.5 $0.00010 $0.00181

Measured 12d ago against content hash 5403ace8f411, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

diag-mysql-deadlock scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/diag-mysql-deadlock/SKILL.md · 203 lines

How it starts

The opening of the file, as written. The whole thing — 203 lines — stays where its author put it; the contents beside it link to each section on GitHub.

MySQL Deadlock Full-Chain Diagnostics

用途

当用户报告 MySQL 死锁或怀疑锁竞争时触发。覆盖:

  • 应用日志出现 Error: 1213 Deadlock found
  • 监控发现 Innodb_deadlocks 计数器持续增长
  • 高峰期锁竞争排查
  • Schema 变更后可能影响锁行为

本技能是自包含诊断 Runbook——所有 SQL、模式分类、输出模板、告警阈值都在本文件内,不依赖外部 references。

输入

  • MySQL 连接信息(host / port / user / password)
  • 可选:应用日志中的死锁片段
  • 可选:已知的表结构和索引信息

输出

  • 结构化死锁分析报告(填充输出模板)
  • 根因判定 + 修复建议(SQL / 代码 / 配置三级)

前置条件

要求
MySQL 权限 PROCESS(查看线程和 InnoDB 状态)
版本 MySQL 5.6+(5.7+ 使用 performance_schema,5.6 回退 information_schema)

诊断步骤

Step 1: 捕获死锁计数与最近状态

-- 死锁计数与锁等待指标
SHOW GLOBAL STATUS LIKE 'Innodb_deadlocks';
SHOW GLOBAL STATUS LIKE 'Innodb_row_lock_waits';
SHOW GLOBAL STATUS LIKE 'Innodb_row_lock_time_avg';

-- 完整 InnoDB 状态(包含 LATEST DETECTED DEADLOCK 区块)
SHOW ENGINE INNODB STATUS;

Step 2: 检查当前锁等待(MySQL 5.7+)

-- 谁阻塞了谁
SELECT
  waiting_trx.trx_id AS waiting_trx,
  blocking_trx.trx_id AS blocking_trx,
  waiting_trx.trx_state AS wait_state,
  waiting_trx.trx_started AS wait_started,
  LEFT(waiting_trx.trx_query, 200) AS wait_query,
  LEFT(blocking_trx.trx_query, 200) AS block_query
FROM performance_schema.data_lock_waits w
JOIN information_schema.innodb_trx waiting_trx ON w.requesting_engine_transaction_id = waiting_trx.trx_id
JOIN information_schema.innodb_trx blocking_trx ON w.blocking_engine_transaction_id = blocking_trx.trx_id;

-- MySQL 5.6 回退:
SELECT * FROM information_schema.innodb_trx ORDER BY trx_started;

Step 3: 查找长事务

-- 运行超过 60 秒的事务
SELECT
  trx_id, trx_state, trx_started,
  TIMESTAMPDIFF(SECOND, trx_started, NOW()) AS duration_sec,
  trx_tables_locked, trx_rows_locked,
  LEFT(trx_query, 200) AS current_query
FROM information_schema.innodb_trx
WHERE TIMESTAMPDIFF(SECOND, trx_started, NOW()) > 60
ORDER BY trx_started;

Step 4: 判定死锁模式

SHOW ENGINE INNODB STATUS 的 LATEST DETECTED DEADLOCK 区块提取并分类:

模式 特征 典型修复
AB-BA 事务 A 锁行1→行2,B 锁行2→行1 统一访问顺序
Gap Lock Next-key lock 在索引间隙上 缩小扫描范围、使用 RC 隔离级别
FK Cascade 外键触发级联锁 在 FK 列上加索引
Auto-Inc 并发 insert 竞争自增锁 innodb_autoinc_lock_mode=2
Lock Upgrade S-lock 升级为 X-lock 缩小事务范围

Read the full file on GitHub · 203 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 203 lines · 99 tokens per session scan A 5403ace8f411

Subscribe to this mod's changes

diag-mysql-deadlock is a skill published in the GitHub repository seed-forge/harness-ai-kit (22 stars, last pushed 11d ago), licensed Apache-2.0. It adds 99 tokens to every session and 1,806 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

sql-optimization-patterns

Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

wshobson/agents · 44 tokens

lcx-report-bug

Create a high-signal bug issue or PR in the repo that owns the defect. Use this whenever the user asks to report, file, open, or triage a LazyCodex, lazycodex-ai, omo-codex, Codex plugin, or upstream Codex CLI bug, especially when they need source-backed root cause, reproduction steps, fix guidance, and GitHub routing.

code-yeongyu/oh-my-openagent · 85 tokens

ast-grep

Searches and rewrites code by AST shape across 25 languages. Use when the target is a syntax pattern (every call/class/import shaped like X, a codemod, a YAML rule) rather than literal text; for plain strings, comments, or filenames, use rg.

code-yeongyu/oh-my-openagent · 61 tokens

debugging

Runs a hypothesis-driven debugging loop across any language or binary, escalating to orthogonal oracle angles and locking the fix with a failing test. Use for crashes, silent failures, hangs, wrong responses, memory leaks, async misbehavior, or reverse engineering.

code-yeongyu/oh-my-openagent · 53 tokens

lcx-doctor

Diagnose LazyCodex and Codex CLI installation health against the latest sources. Use whenever the user asks for a doctor or health check, says LazyCodex, lazycodex-ai, omo-codex, or Codex behaves oddly after an install, update, or config change, suspects a stale, drifted, or broken setup, or wants the local install…

code-yeongyu/oh-my-openagent · 93 tokens

remove-deadcode

Remove unused code from this project with ultrawork mode, LSP-verified safety, atomic commits. Triggers: remove dead code, dead code, cleanup, remove unused.

code-yeongyu/oh-my-openagent · 41 tokens