This page in other versions: 1.0.3

7.4. Monitoring global DDL locks

The global DDL lock, used in DDL replication, can cancel and/or block concurrent writes and other DDL. So it can be important to determine what is taking the lock, whether it holds it or is still trying to acquire it, and how long it's been trying or has held the lock.

DDL locking activity can be traced using the bdr.trace_ddl_locks_level setting using the PostgreSQL log files, which provides the most complete and useful way to see DDL locking activity. It is strongly recommended that you enable DDL lock tracing.

The bdr.bdr_global_locks catalog also provides some visibility into DDL locking state. When a DDL lock is held, the node that holds the DDL lock will not have any row in this table. The other nodes will all have single-row entries like:

bdr_testdb=# select * from bdr.bdr_global_locks ;
locktype |    owning_sysid     | owning_timeline | owning_datid | owner_created_lock_at |   acquired_sysid    | acquired_timeline | acquired_datid | acquired_lock_at |  state   
 ddl_lock | 6313760379784308337 |               1 |        16385 | 1DC11/2CEB874C        | 6313760193895071967 |                 1 |          16385 |                  | acquired
 (1 row)

which indicate the node that holds the lock or is trying to acquire the lock.

See Section 8.1.1 for more detail on how the global DDL lock works.