Skip to content

pg-upgrade on HA instances fail because Repmgr was renamed to RepmgrHandler

In !3489 (merged), we renamed Repmgr and Consul classes to RepmgrHandler and ConsulHandler respectively. This broke pg-upgrade in HA instances with the log

Checking for an omnibus managed postgresql: OK
Checking if postgresql['version'] is set: OK
Checking if we already upgraded: NOT OK
Checking for a newer version of PostgreSQL to install
Upgrading PostgreSQL to 11.7
Checking if PostgreSQL bin files are symlinked to the expected location: OK
Waiting 30 seconds to ensure tasks complete before PostgreSQL upgrade.
See https://docs.gitlab.com/omnibus/settings/database.html#upgrade-packaged-postgresql-server for details
If you do not want to upgrade the PostgreSQL server at this time, enter Ctrl-C and see the documentation for details

Please hit Ctrl-C now if you want to cancel the operation.
..............................Detected an HA cluster.
Secondary node detected.
Promoting the database
Running restart on postgresql:ok: run: postgresql: (pid 7355) 0s
Running restart on postgresql: OK
Unregistering secondary node from cluster
Traceback (most recent call last):
    6: from /opt/gitlab/embedded/bin/omnibus-ctl:23:in `<main>'
    5: from /opt/gitlab/embedded/bin/omnibus-ctl:23:in `load'
    4: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/omnibus-ctl-0.6.0/bin/omnibus-ctl:31:in `<top (required)>'
    3: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/omnibus-ctl-0.6.0/lib/omnibus-ctl.rb:746:in `run'
    2: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/omnibus-ctl-0.6.0/lib/omnibus-ctl.rb:204:in `block in add_command_under_category'
    1: from /opt/gitlab/embedded/service/omnibus-ctl/pg-upgrade.rb:178:in `block in load_file'
/opt/gitlab/embedded/service/omnibus-ctl/pg-upgrade.rb:236:in `ha_secondary_upgrade': uninitialized constant Omnibus::Ctl::Repmgr (NameError)

Workaround

Edit the file /opt/gitlab/embedded/service/omnibus-ctl/pg-upgrade.rb and line 236 (Repmgr::Standby.unregister({})) with the following

RepmgrHandler::Standby.unregister({})
Edited by Balasankar 'Balu' C