Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 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 @@ -39,6 +39,7 @@ MOUNT_POINT="/data_migration"
LOG_FILE="/var/log/pg-upgrade-initiate.log"

POST_UPGRADE_EXTENSION_SCRIPT="/tmp/pg_upgrade/pg_upgrade_extensions.sql"
POST_UPGRADE_POSTGRES_PERMS_SCRIPT="/tmp/pg_upgrade/pg_upgrade_postgres_perms.sql"
OLD_PGVERSION=$(run_sql -A -t -c "SHOW server_version;")

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

echo "Making sure postgres still has access to pg_shadow"
cat << EOF >> $POST_UPGRADE_POSTGRES_PERMS_SCRIPT
DO \$\$
begin
if exists (select from pg_authid where rolname = 'pg_read_all_data') then
execute('grant pg_read_all_data to postgres');
end if;
end
\$\$;
grant pg_signal_backend to postgres;
EOF

if [ -f $POST_UPGRADE_POSTGRES_PERMS_SCRIPT ]; then
retry 5 run_sql -f $POST_UPGRADE_POSTGRES_PERMS_SCRIPT
fi

if [ -z "$IS_CI" ] && [ -z "$IS_LOCAL_UPGRADE" ]; then
echo "Unmounting data disk from ${MOUNT_POINT}"
retry 3 umount $MOUNT_POINT
Expand Down
Loading