TL;DR: Is it safe to provide shared libraries from multiple environments in LD_LIBRARY_PATH
to pg_upgrade
? If not, can I somehow tell pg_upgrade
the directory it should take its shared libraries from only for the old-bindir
?
I’m trying to upgrade a PostgreSQL server from 11.x to 16.x using pg_upgrade. I’m doing this inside a bitnami/postgresql container. Hence some paths are bitnami-specific. But it should not affect the actual upgrade (correct me if I’m wrong here).
pg_upgrade
needs both the old and new binaries available. So I temporarily copied the binaries from the old 11.x container to the new one to /tmp/pg_upgrade/postgresql-11/bin/
and ran the following command:
pg_upgrade --link
--old-bindir=/tmp/pg_upgrade/postgresql-11/bin
--old-datadir=/bitnami/postgresql/data
--old-options="--config-file=$POSTGRESQL_CONF_FILE"
--old-options="--hba_file=$POSTGRESQL_PGHBA_FILE"
--new-bindir=/opt/bitnami/postgresql/bin
--new-datadir=/bitnami/postgresql/data_new
--new-options="--config-file=$POSTGRESQL_CONF_FILE"
--new-options="--hba_file=$POSTGRESQL_PGHBA_FILE"
This fails with “/tmp/pg_upgrade/postgresql-11/bin/postgres: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory”
postgres@defectdojo-postgresql-0:/bitnami/postgresql$ pg_upgrade --link
--old-bindir=/tmp/pg_upgrade/postgresql-11/bin
--old-datadir=/bitnami/postgresql/data
--old-options="--config-file=$POSTGRESQL_CONF_FILE"
--old-options="--hba_file=$POSTGRESQL_PGHBA_FILE"
--new-bindir=/opt/bitnami/postgresql/bin
--new-datadir=/bitnami/postgresql/data_new
--new-options="--config-file=$POSTGRESQL_CONF_FILE"
--new-options="--hba_file=$POSTGRESQL_PGHBA_FILE"
/tmp/postgresql-11/bin/postgres: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
no data was returned by command ""/tmp/postgresql-11/bin/postgres" -V"
check for "/tmp/pg_upgrade/postgresql-11/bin/postgres" failed: cannot execute
Failure, exiting
postgres@defectdojo-postgresql-0:/bitnami/postgresql$
Following this guide I also copied the shared libraries (/usr/lib/x86_64-linux-gnu
) from the old 11.x image to the new 16.x container and configured them in the LD_LIBRARY_PATH
variable, only to have a similar issue now with the new binaries
postgres@defectdojo-postgresql-0:/bitnami/postgresql$ LD_LIBRARY_PATH="/tmp/pg_upgrade/libs" pg_upgrade --link
--old-bindir=/tmp/pg_upgrade/postgresql-11/bin
--old-datadir=/bitnami/postgresql/data
--old-options="--config-file=$POSTGRESQL_CONF_FILE"
--old-options="--hba_file=$POSTGRESQL_PGHBA_FILE"
--new-bindir=/opt/bitnami/postgresql/bin
--new-datadir=/bitnami/postgresql/data_new
--new-options="--config-file=$POSTGRESQL_CONF_FILE"
--new-options="--hba_file=$POSTGRESQL_PGHBA_FILE"
/opt/bitnami/postgresql/bin/postgres: /tmp/pg_upgrade/libs/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /lib/x86_64-linux-gnu/libicuuc.so.72)
no data was returned by command ""/opt/bitnami/postgresql/bin/postgres" -V"
check for "/opt/bitnami/postgresql/bin/postgres" failed: cannot execute
Failure, exiting
postgres@defectdojo-postgresql-0:/bitnami/postgresql$
I got it working by adding both the old and the new shared library paths to the LD_LIBRARY_PATH
variable
LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu:/tmp/pg_upgrade/libs" pg_upgrade --link
...
But is this safe? If not, can I somehow tell pg_upgrade
to use a specific shared libs directory only for the binaries from old-bindir
?