Show HN: pglockanalyze - See the locks your Postgres migrations will acquire

7 pasxizeis 0 5/31/2025, 11:59:36 AM github.com ↗
Hello! I created this 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.

Curious to see what others think; feedback is more than welcome!

https://github.com/agis/pglockanalyze

Thanks in advance

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

Comments (0)

No comments yet