Skip to content

Commit 51c9e5a

Browse files
authored
chore: upgrade scripts - only update libpq reference if major version older than current (#606)
* chore: only update libpq reference if major version older than current * chore: extra handling for extensions * chore: handle symlink for new pg binaries
1 parent bccf3e4 commit 51c9e5a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ansible/files/admin_api_scripts/pg_upgrade_initiate.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ cleanup() {
6060

6161
if [ -d "${MOUNT_POINT}/pgdata/pg_upgrade_output.d/" ]; then
6262
echo "Copying pg_upgrade output to /var/log"
63-
cp -R "${MOUNT_POINT}/pgdata/pg_upgrade_output.d/" /var/log/
63+
cp -R "${MOUNT_POINT}/pgdata/pg_upgrade_output.d/" /var/log/ || true
6464
fi
6565

6666
if [ -L /var/lib/postgresql ]; then
@@ -136,6 +136,7 @@ function initiate_upgrade {
136136
if [[ "$OLD_PGVERSION" =~ 14* ]]; then
137137
SHARED_PRELOAD_LIBRARIES=$(echo "$SHARED_PRELOAD_LIBRARIES" | sed "s/wrappers, //")
138138
fi
139+
SHARED_PRELOAD_LIBRARIES=$(echo "$SHARED_PRELOAD_LIBRARIES" | sed "s/pg_cron, //")
139140

140141
PGDATAOLD=$(cat /etc/postgresql/postgresql.conf | grep data_directory | sed "s/data_directory = '\(.*\)'.*/\1/")
141142

@@ -165,7 +166,7 @@ function initiate_upgrade {
165166
# Make latest libpq available to pg_upgrade
166167
mkdir -p /usr/lib/postgresql/lib/aarch64
167168
if [ ! -L /usr/lib/postgresql/lib/aarch64/libpq.so.5 ]; then
168-
ln -s "$PGLIBNEW/libpq.so.5" /usr/lib/postgresql/lib/aarch64/libpq.so.5
169+
ln -s "$PGLIBNEW/libpq.so.5" /usr/lib/postgresql/lib/aarch64/libpq.so.5
169170
fi
170171

171172
# upgrade job outputs a log in the cwd; needs write permissions
@@ -223,6 +224,7 @@ function initiate_upgrade {
223224
--new-datadir=${PGDATANEW} \
224225
--jobs="${WORKERS}" \
225226
--old-options='-c config_file=/etc/postgresql/postgresql.conf' \
227+
--old-options="-c shared_preload_libraries='${SHARED_PRELOAD_LIBRARIES}'" \
226228
--new-options="-c data_directory=${PGDATANEW}" \
227229
--new-options="-c shared_preload_libraries='${SHARED_PRELOAD_LIBRARIES}'"
228230
EOF
@@ -240,6 +242,10 @@ EOF
240242
fi
241243
ln -s /var/lib/postgresql.bak/data /var/lib/postgresql/data
242244
fi
245+
246+
if [ ! -L /var/lib/postgresql/data ]; then
247+
ln -s /data/pgdata /var/lib/postgresql/data
248+
fi
243249

244250
echo "9. Stopping postgres; running pg_upgrade"
245251
systemctl stop postgresql

0 commit comments

Comments
 (0)