supabase-postgres.git / summary / log / commit / refs
commit bd0ed77f2ed3edad5e04f2aabf046937f5962400
Author: Paul Cioanca <paul.cioanca@supabase.io>
Commit: GitHub <noreply@github.com>
Date: Wed Jan 17 14:19:07 2024 +0000
generate locales pre-upgrade; remove libpq symlinking (#856)
* chore: patch pg_cron post-upgrade; generate locales pre-upgrade; remove libpq symlinking
* chore: revert pg_cron fix
* chore: update locale check
.../pg_upgrade_scripts/initiate.sh | 39 +++++++++-------------
1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh b/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh
index 3d762e18..9c4fd156 100755
--- a/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh
+++ b/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh
@@ -85,11 +85,6 @@ cleanup() {
fi
fi
- if [ -f "/usr/lib/postgresql/lib/aarch64/libpq.so.5.bak" ]; then
- rm /usr/lib/postgresql/lib/aarch64/libpq.so.5
- mv /usr/lib/postgresql/lib/aarch64/libpq.so.5.bak /usr/lib/postgresql/lib/aarch64/libpq.so.5
- fi
-
if [ "$IS_DRY_RUN" = false ]; then
echo "Restarting postgresql"
systemctl enable postgresql
@@ -183,16 +178,6 @@ function initiate_upgrade {
chown -R postgres:postgres "/tmp/pg_upgrade_bin/$PGVERSION"
- # Make latest libpq available to pg_upgrade
- mkdir -p /usr/lib/aarch64-linux-gnu
- if [ -f "/usr/lib/aarch64-linux-gnu/libpq.so.5" ]; then
- mv /usr/lib/aarch64-linux-gnu/libpq.so.5 /usr/lib/aarch64-linux-gnu/libpq.so.5.bak
- fi
- if [ -f "${PG_UPGRADE_BIN_DIR}/libpq.so.5" ]; then
- cp "${PG_UPGRADE_BIN_DIR}/libpq.so.5" "${PGLIBNEW}/libpq.so.5"
- fi
- ln -s "${PGLIBNEW}/libpq.so.5" /usr/lib/aarch64-linux-gnu/libpq.so.5
-
# upgrade job outputs a log in the cwd; needs write permissions
mkdir -p /tmp/pg_upgrade/
chown -R postgres:postgres /tmp/pg_upgrade/
@@ -208,15 +193,21 @@ function initiate_upgrade {
apt-get update && apt --fix-broken install -y libprotobuf-c1
fi
+ echo "4. Setup locale if required"
+ if ! grep -q "^en_US.UTF-8" /etc/locale.gen ; then
+ echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
+ locale-gen
+ fi
+
if [ "$IS_DRY_RUN" = false ]; then
# awk NF==3 prints lines with exactly 3 fields, which are the block devices currently not mounted anywhere
# excluding nvme0 since it is the root disk
- echo "4. Determining block device to mount"
+ echo "5. Determining block device to mount"
BLOCK_DEVICE=$(lsblk -dprno name,size,mountpoint,type | grep "disk" | grep -v "nvme0" | awk 'NF==3 { print $1; }')
echo "Block device found: $BLOCK_DEVICE"
mkdir -p "$MOUNT_POINT"
- echo "5. Mounting block device"
+ echo "6. Mounting block device"
sleep 5
e2fsck -pf "$BLOCK_DEVICE"
@@ -234,10 +225,10 @@ function initiate_upgrade {
chmod 600 /etc/postgresql-custom/pgsodium_root.key
fi
- echo "6. Disabling extensions and generating post-upgrade script"
+ echo "7. Disabling extensions and generating post-upgrade script"
handle_extensions
- echo "7. Granting SUPERUSER to postgres user"
+ echo "8. Granting SUPERUSER to postgres user"
run_sql -c "ALTER USER postgres WITH SUPERUSER;"
if [ -d "/usr/share/postgresql/${PGVERSION}" ]; then
@@ -275,7 +266,7 @@ function initiate_upgrade {
export LD_LIBRARY_PATH="${PGLIBNEW}"
- echo "8. Creating new data directory, initializing database"
+ echo "9. Creating new data directory, initializing database"
chown -R postgres:postgres "$MOUNT_POINT/"
rm -rf "${PGDATANEW:?}/"
su -c "$PGBINNEW/initdb -L $PGSHARENEW -D $PGDATANEW/" -s "$SHELL" postgres
@@ -297,7 +288,7 @@ EOF
if [ "$IS_DRY_RUN" = true ]; then
UPGRADE_COMMAND="$UPGRADE_COMMAND --check"
else
- echo "9. Stopping postgres; running pg_upgrade"
+ echo "10. Stopping postgres; running pg_upgrade"
# Extra work to ensure postgres is actually stopped
# Mostly needed for PG12 projects with odd systemd unit behavior
@@ -312,7 +303,7 @@ EOF
su -c "$UPGRADE_COMMAND" -s "$SHELL" postgres
# copying custom configurations
- echo "10. Copying custom configurations"
+ echo "11. Copying custom configurations"
mkdir -p "$MOUNT_POINT/conf"
cp -R /etc/postgresql-custom/* "$MOUNT_POINT/conf/"
@@ -320,12 +311,12 @@ EOF
rm -f "$MOUNT_POINT/conf/wal-g.conf"
# copy sql files generated by pg_upgrade
- echo "11. Copying sql files generated by pg_upgrade"
+ echo "12. Copying sql files generated by pg_upgrade"
mkdir -p "$MOUNT_POINT/sql"
cp /tmp/pg_upgrade/*.sql "$MOUNT_POINT/sql/" || true
chown -R postgres:postgres "$MOUNT_POINT/sql/"
- echo "12. Cleaning up"
+ echo "13. Cleaning up"
cleanup "complete"
}
[parent: 2d0bb0528a1d]