Hubert Lubaczewski wants to make a change:
I once wrote about this problem, but given that we now have DO blocks and procedures I can make nicer, easy to use example.
Over the years there have been many improvements to how long ALTER TABLE can take. You can now (in some cases) change datatype without rewrite or add default value.
Regardless how fast the thing works, it still needs extremely heavy (though shortlived) lock: Access Exclusive.
Read on to see how you can write a SQL operation that waits for a lock and, if it does not get this lock, retries with backoff.