Skip to content

Commit a8820af

Browse files
authored
chore: fix wrappers' lib name (#774)
* chore: fix wrappers' lib name * chore: limit `find` printing; comments
1 parent 567ace8 commit a8820af

File tree

1 file changed

+24
-0
lines changed
  • ansible/files/admin_api_scripts/pg_upgrade_scripts

1 file changed

+24
-0
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ OLD_PGVERSION=$(run_sql -A -t -c "SHOW server_version;")
4646

4747
POSTGRES_CONFIG_PATH="/etc/postgresql/postgresql.conf"
4848
PGBINOLD="/usr/lib/postgresql/bin"
49+
PGLIBOLD="/usr/lib/postgresql/lib"
4950

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

248249
cp --remove-destination "$PGLIBNEW"/*.control "$PGSHARENEW/extension/"
249250
cp --remove-destination "$PGLIBNEW"/*.sql "$PGSHARENEW/extension/"
251+
252+
# This is a workaround for older versions of wrappers which don't have the expected
253+
# naming scheme, containing the version in their library's file name
254+
# e.g. wrappers-0.1.16.so, rather than wrappers.so
255+
# pg_upgrade errors out when it doesn't find an equivalent file in the new PG version's
256+
# library directory, so we're making sure the new version has the expected (old version's)
257+
# file name.
258+
# After the upgrade completes, the new version's library file is used.
259+
# i.e.
260+
# - old version: wrappers-0.1.16.so
261+
# - new version: wrappers-0.1.18.so
262+
# - workaround to make pg_upgrade happy: copy wrappers-0.1.18.so to wrappers-0.1.16.so
263+
if [ -d "$PGLIBOLD" ]; then
264+
WRAPPERS_LIB_PATH=$(find "$PGLIBNEW" -name "wrappers*so" -print -quit)
265+
if [ -f "$WRAPPERS_LIB_PATH" ]; then
266+
OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit)
267+
if [ -f "$OLD_WRAPPER_LIB_PATH" ]; then
268+
LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")
269+
cp "$WRAPPERS_LIB_PATH" "$PGLIBNEW/${LIB_FILE_NAME}"
270+
fi
271+
fi
272+
fi
273+
250274
export LD_LIBRARY_PATH="${PGLIBNEW}"
251275

252276
echo "8. Creating new data directory, initializing database"

0 commit comments

Comments
 (0)