Skip to content

Commit a627e17

Browse files
dragarciadarora
authored andcommitted
chore: cleanup pgbouncer.get_auth ownership accordingly
1 parent 9e285dd commit a627e17

File tree

1 file changed

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

1 file changed

+17
-0
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ MOUNT_POINT="/data_migration"
3939
LOG_FILE="/var/log/pg-upgrade-initiate.log"
4040

4141
POST_UPGRADE_EXTENSION_SCRIPT="/tmp/pg_upgrade/pg_upgrade_extensions.sql"
42+
POST_UPGRADE_PGBOUNCER_CLEANUP_SCRIPT="/tmp/pg_upgrade/pg_upgrade_pgbouncer_cleanup.sql"
4243
OLD_PGVERSION=$(run_sql -A -t -c "SHOW server_version;")
4344

4445
SERVER_LC_COLLATE=$(run_sql -A -t -c "SHOW lc_collate;")
@@ -132,6 +133,22 @@ cleanup() {
132133
echo "Resetting postgres database connection limit"
133134
retry 5 run_sql -c "ALTER DATABASE postgres CONNECTION LIMIT -1;"
134135

136+
echo "Making sure postgres still has access to pg_shadow"
137+
cat << EOF >> $POST_UPGRADE_PGBOUNCER_CLEANUP_SCRIPT
138+
DO \$\$
139+
BEGIN
140+
IF EXISTS (SELECT 1 FROM pg_views WHERE viewname = 'pg_shadow' AND viewowner = 'supabase_admin') THEN
141+
ALTER function pgbouncer.get_auth owner to supabase_admin;
142+
GRANT EXECUTE ON FUNCTION pgbouncer.get_auth(p_usename TEXT) TO postgres;
143+
END IF;
144+
END;
145+
\$\$;
146+
EOF
147+
148+
if [ -f $POST_UPGRADE_PGBOUNCER_CLEANUP_SCRIPT ]; then
149+
retry 5 run_sql -f $POST_UPGRADE_PGBOUNCER_CLEANUP_SCRIPT
150+
fi
151+
135152
if [ -z "$IS_CI" ] && [ -z "$IS_LOCAL_UPGRADE" ]; then
136153
echo "Unmounting data disk from ${MOUNT_POINT}"
137154
retry 3 umount $MOUNT_POINT

0 commit comments

Comments
 (0)