Postgres Pro Shardman provides API for application to get cluster-wide advisory locks.
They are similar to PostgreSQL advisory locks,
but are respected on all cluster nodes. Advisory locks and global
cluster-wide advisory locks work simultaneously and do not conflict
with each other, as global cluster locks use its own locktag type.
Both these lock types are shown in the
pg_locks
view and have the shardman value in
locktype.
When global lock is taken, a coordinator sends
a lock request to each node in a predefined order (based on rgid).
When it's a usual lock request, the lock is considered granted
when the statement succeeds on all nodes.
When it's a try-lock request, the lock is also considered granted when it
could be taken on all nodes. If one of the nodes couldn't take the
lock, the try-lock function returns false.
If one of the nodes returned result is
different from earlier received (false
after true or true after
false), it is considered to be an
error.
To see cluster-wide advisory lock functions, refer to Advisory Lock Functions for Distributed System.