pg_restore ERROR: could not find function "get_local_node_id" in file "/usr/lib/postgresql/14/lib/repmgr.so"
Hi,
I am trying to upgrade postgres 9.6 to postgres 14.1, which appeared 11th Nov 2021 in apt packages, on Ubuntu 20.04 via "pg_upgrade" cmd on postgres primary node and I am facing the issue. pg_upgrade from 9.6 to postgres 14.0 pg_upgrade went smoothly last week with no error.
Here it is the error from "pg_upgrade" (despite pg_upgrade --check is OK) from pg_upgrade_dump_16385.log:
pg_restore: error: could not execute query: ERROR: could not find function "get_local_node_id" in file "/usr/lib/postgresql/14/lib/repmgr.so"
Command was: CREATE FUNCTION "repmgr"."get_local_node_id"() RETURNS integer
LANGUAGE "c" STRICT
AS '$libdir/repmgr', 'get_local_node_id';
-- For binary upgrade, handle extension membership the hard way
ALTER EXTENSION "repmgr" ADD FUNCTION "repmgr"."get_local_node_id"();
I dunno how to implement this ALTER EXTENSION as on 9.6 is already registered If I register it on new db 14.1 "pg_upgrade --check" won't allow me to continue upgrade.
Is it because of postgresql-14-repmgr-dbgsym version which still points to 14.0 instead to 14.1?
postgresql-14-repmgr-dbgsym is already the newest version (5.3.0-1.pgdg20.04+1)
shouldn't it be 5.3.1-1 version here instead?
Here is the list of packages installed:
$ sudo apt list --installed | grep postgres
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
postgresql-14-repmgr-dbgsym/focal-pgdg,now 5.3.0-1.pgdg20.04+1 amd64 [installed]
postgresql-14-repmgr/focal-pgdg,now 5.3.0-1.pgdg20.04+1 amd64 [installed]
postgresql-14/focal-pgdg,now 14.1-1.pgdg20.04+1 amd64 [installed]
postgresql-9.6-repmgr/now 5.2.0-2.pgdg20.04+1 amd64 [installed,upgradable to: 5.3.0-1.pgdg20.04+1]
postgresql-9.6/now 9.6.23-1.pgdg20.04+1 amd64 [installed,upgradable to: 9.6.24-1.pgdg20.04+1]
postgresql-client-14/focal-pgdg,now 14.1-1.pgdg20.04+1 amd64 [installed]
postgresql-client-9.6/now 9.6.23-1.pgdg20.04+1 amd64 [installed,upgradable to: 9.6.24-1.pgdg20.04+1]
postgresql-client-common/now 231.pgdg20.04+1 all [installed,upgradable to: 232.pgdg20.04+1]
postgresql-common/now 231.pgdg20.04+1 all [installed,upgradable to: 232.pgdg20.04+1]
postgresql-contrib-9.6/now 9.6.23-1.pgdg20.04+1 amd64 [installed,upgradable to: 9.6.24-1.pgdg20.04+1]
postgresql-server-dev-14/focal-pgdg,now 14.1-1.pgdg20.04+1 amd64 [installed]
postgresql-server-dev-9.6/now 9.6.23-1.pgdg20.04+1 amd64 [installed,upgradable to: 9.6.24-1.pgdg20.04+1]
Thank you for any tip or advice.
Kind regards, Stanisław Kodzis
This kind of error occurs with extensions where the extension version on the old and new servers is different, and the new extension version does not contain a function referenced by the old extension version. In this case with repmgr, the function get_local_node_id was renamed to repmgrd_get_local_node_id in repmgr 5.3, to avoid a naming clash with a function in another extension.
Unfortunately pg_upgrade is unable to catch this kind of issue, which is why we recommend upgrading repmgr on the old node first (see: https://repmgr.org/docs/current/upgrading-and-pg-upgrade.html).