Electric.Postgres.LockBreakerConnection (electric v1.2.4)
View SourceA Postgres connection that is used to break an abandoned lock.
Electric takes out a session-level advisory lock on a separate connection to better manage the ownership of the replication slot. Unfortunately, we have seen instances (especially on Neon), where the Electric disconnects, but the lock is not auto-released.
For these cases, this breaker exists - it'll connect to the database, and check that for a given lock name, if that lock is taken, there also exists an active replication slot with the same name. If not, it'll terminate the backend that is holding the lock, under the assumption that it's one of the abandoned locks.
Summary
Types
Functions
@spec start(options()) :: {:ok, pid()} | {:error, Postgrex.Error.t() | term()}