Skip to content

Commit

Permalink
chore: fix wrappers' lib name (#774)
Browse files Browse the repository at this point in the history
* chore: fix wrappers' lib name

* chore: limit `find` printing; comments
  • Loading branch information
pcnc authored Oct 26, 2023
1 parent 567ace8 commit a8820af
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ OLD_PGVERSION=$(run_sql -A -t -c "SHOW server_version;")

POSTGRES_CONFIG_PATH="/etc/postgresql/postgresql.conf"
PGBINOLD="/usr/lib/postgresql/bin"
PGLIBOLD="/usr/lib/postgresql/lib"

# If upgrading from older major PG versions, disable specific extensions
if [[ "$OLD_PGVERSION" =~ ^14.* ]]; then
Expand Down Expand Up @@ -247,6 +248,29 @@ function initiate_upgrade {

cp --remove-destination "$PGLIBNEW"/*.control "$PGSHARENEW/extension/"
cp --remove-destination "$PGLIBNEW"/*.sql "$PGSHARENEW/extension/"

# This is a workaround for older versions of wrappers which don't have the expected
# naming scheme, containing the version in their library's file name
# e.g. wrappers-0.1.16.so, rather than wrappers.so
# pg_upgrade errors out when it doesn't find an equivalent file in the new PG version's
# library directory, so we're making sure the new version has the expected (old version's)
# file name.
# After the upgrade completes, the new version's library file is used.
# i.e.
# - old version: wrappers-0.1.16.so
# - new version: wrappers-0.1.18.so
# - workaround to make pg_upgrade happy: copy wrappers-0.1.18.so to wrappers-0.1.16.so
if [ -d "$PGLIBOLD" ]; then
WRAPPERS_LIB_PATH=$(find "$PGLIBNEW" -name "wrappers*so" -print -quit)
if [ -f "$WRAPPERS_LIB_PATH" ]; then
OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit)
if [ -f "$OLD_WRAPPER_LIB_PATH" ]; then
LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")
cp "$WRAPPERS_LIB_PATH" "$PGLIBNEW/${LIB_FILE_NAME}"
fi
fi
fi

export LD_LIBRARY_PATH="${PGLIBNEW}"

echo "8. Creating new data directory, initializing database"
Expand Down

0 comments on commit a8820af

Please sign in to comment.