Remix.run Logo
pasxizeis 5 days ago

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. Then, it will output the results for each statement.

I think there's merit in this idea, that said it's very much an experiment so there could be flaws and/or corner cases that this strategy won't work well for.

It's meant to act as a complement, not a replacement, to things like static analysis and the official Postgres docs.

https://github.com/agis/pglockanalyze

[1] typically an ephemeral database spawned by your CI pipeline