pglockanalyze
A CLI tool that makes reasoning about Postgres locks easier. Given a database (typically an ephemeral one spawned by a CI pipeline) and a set of DDL statements or migrations, it opens a transaction, executes the statements, reads the pg_locks view to analyze the locks they acquire, rolls back or commits the transaction depending on flags, and outputs results for each statement. It acts as a complement, not a replacement, to static analysis and the official Postgres docs.
What it addresses
Reasoning about the locks acquired by Postgres DDL statements and migrations is difficult; static analysis and documentation alone don't show what locks statements actually take.
Shared over time
Each entry reflects what was shared on that date. Details may have changed since then.
pglockanalyze
A CLI tool that makes reasoning about Postgres locks easier. Given a database (typically an ephemeral one spawned by a CI pipeline) and a set of DDL statements or migrations, it opens a transaction, executes the statements, reads the pg_locks view to analyze the locks they acquire, rolls back or commits the transaction depending on flags, and outputs results for each statement. It acts as a complement, not a replacement, to static analysis and the official Postgres docs.
Problem: Reasoning about the locks acquired by Postgres DDL statements and migrations is difficult; static analysis and documentation alone don't show what locks statements actually take.
Posted by @pasxizeis · Original source ↗
Source text · @pasxizeis · · Source ↗
A CLI tool to make reasoning about Postgres locks a bit easier. Given a database[1] and a set of DDL statements/migrations you want to check, pglockanalyze will open a transaction, execute the statements, read the pg_locks view to analyze the locks they acquire and rollback (or commit, depending on the flags you passed) the transaction.
pglockanalyze
This tool runs database migrations and observes at runtime which PostgreSQL locks they acquire by opening a transaction, executing the statement, and watching the pg_locks view from a separate connection before rolling back or committing. It reports the acquired locks as a comment on the pull request, giving developers a data point for judging whether a migration is safe to deploy, and can be used as a CLI, a library, or a ready-made GitHub Action. It is an early-stage proof of concept written in Rust.
Problem: Seemingly innocent migrations can end up acquiring unexpected PostgreSQL locks, and there was no runtime visibility into which locks a migration acquires before deployment.
Posted by @pasxizeis · Original source ↗
Source text · @pasxizeis · · Source ↗
A "Postgres lock diagnostics" tool for migrations. We've been bitten a few times, by seemingly innocent migrations that ended up acquiring locks we did not expect (yes, RTFM).