Managing PostgreSQL replication slots for HA and Geo
In Geo, we would really like to mandate the use of PostgreSQL replication slots to ensure that the secondary can recover if the primary goes offline for an arbitrary amount of time.
One of the challenges here is to create/add replication slots when a node is added or removed. Ideally, we'd be able to modify this within the application, but the normal gitlab
login doesn't have permission to do this:
$ sudo gitlab-rails dbconsole
psql (9.6.1)
Type "help" for help.
gitlabhq_production=> select * from pg_replication_slots;
slot_name | plugin | slot_type | datoid | database | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn
-----------+--------+-----------+--------+----------+--------+------------+------+--------------+-------------+---------------------
(0 rows)
gitlabhq_production=> select * from pg_create_physical_replication_slot('geo_secondary');
ERROR: must be superuser or replication role to use replication slots
That leaves the options:
- Manually creating them with the superuser account (e.g.
gitlab-psql
) - Having omnibus add/remove them with the superuser account
- Having some other process that manages this
With GitLab PostgreSQL HA, have you considered how you might do this?
/cc: @ibaum, @joshlambert, @brodock