xataio / pgroll

PostgreSQL zero-downtime migrations made easy

Home Page:https://www.xata.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Retry on DDL lock acquisition failures

andrew-farries opened this issue · comments

DDL operations are run in a session in which SET lock_timout TO xms' has been set (x defaults to 500 but can be specified with the --lock-timeout parameter). This ensures that a long running query can't cause other queries to queue up behind the DDL operation as it waits to acquire its lock.

The current behaviour if a DDL operation times out when requesting a lock is to fail, forcing the user to retry the migration operation (start, rollback, or complete).

pgroll should automatically retry to acquire the lock in such situations to prevent the need for manual intervention.

Nice idea, introducing an exponential backof algorithm with jitter can improve things here. Some references: