Database Transaction Monitor 技能:找出 PostgreSQL 等待锁的会话
EnglishClaude Code 安装步骤
- 从 GitHub 固定提交获取完整的 `plugins/database/database-transaction-monitor/skills/monitoring-database-transactions` 目录。
- 复制到目标项目的 `.claude/skills/`,确认 `.claude/skills/monitoring-database-transactions/SKILL.md`,再从项目根目录启动 Claude Code,输入 `/monitoring-database-transactions`。
中文摘要
用 Claude Code 读取 PostgreSQL 事务状态和阻塞关系,把被阻塞进程与持锁会话对应起来。
SKILL.md 中文导读
可复现示例
在本地 lock_demo 表放一行,分别让 A、B 更新同一 ID,A 保持事务打开。第三个会话用 pg_blocking_pids 检查 B,之后在测试会话执行 ROLLBACK。工作步骤
- 让会话 A 在未提交事务中更新样例行,会话 B 请求更新同一行。用第三个会话检查阻塞关系。
- 结合 pg_stat_activity 的事务起始时间和 pg_blocking_pids 的结果写只读报告。关闭实验事务并复查等待消失。
验收方法
等待期间报告能定位 A 为阻塞者。测试事务结束后阻塞关系消失,无持久数据变更。
GitHub 原文 · 更新日期
适用环境
准备自己的可重建 PostgreSQL 测试库和三个 psql 会话。示例仅操作一条合成记录。
常见问题
查询开始时间就是事务开始时间吗?
区分 query_start 和 xact_start。用 xact_start 判断事务年龄,用 query_start 判断当前查询时长。
相关指南
相关推荐
groq-install-auth 技能
jeremylongshore/claude-code-plugins-plus-skills
anima-common-errors 技能
jeremylongshore/claude-code-plugins-plus-skills
apple-notes-hello-world 技能
jeremylongshore/claude-code-plugins-plus-skills
castai-hello-world 技能
jeremylongshore/claude-code-plugins-plus-skills
cohere-local-dev-loop 技能
jeremylongshore/claude-code-plugins-plus-skills
figma-security-basics 技能
jeremylongshore/claude-code-plugins-plus-skills