logoalt Hacker News

nijave • today at 1:31 PM • 1 reply • view on HN

I think you could automate this with 2 transactions

- connection A, lock timeout=0, acquire unwanted lock

- connection B, lock timeout=0, run migration

- collection A, rollback

Then connection B will fail if it tries to acquire an undesirable lock since it will conflict with A. You'd be adding a very small window when you're actually holding the undesirable lock, though


Replies

orf • today at 1:49 PM

This is essentially how my tool discovers locks for a given arbitrary DDL statement.