Simultaneous lock on HA table in postgreSQL


I currently have 2 vaults in HA with a postgreSQL storage backend and something is not very clear for me.
If the vaults are unseal at the same time and send the request to be the active node at the same time, how vault handle that ?

One will try 2 seconds after and the other will try like 4 seconds later ? Do have any ideas ?


They update a locks table using an “upsert” strategy, such that only one Vault instance will successfully insert or update the row corresponding to the vault cluster lock, and the one who does so becomes the active node. There is a timestamp column in the table, and the active node must continuously update the table to keep the timestamp in the future. If it fails to, the other node, which is continuously trying to steal the lock, will succeed in replacing the row with its own, and will then become the active node.