Skip to content

fix: rescope pg_graphql and pg_cron event triggers during pg_upgrade - #2478

Merged
utkarash2991 merged 5 commits into
developfrom
utkarashsingh/pg-graphql-trigger-rescope-upgrade
Sep 25, 2026
Merged

utkarash2991 merged 5 commits into
developfrom
utkarashsingh/pg-graphql-trigger-rescope-upgrade

Conversation

@utkarash2991

@utkarash2991 utkarash2991 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Old projects still have issue_pg_graphql_access scoped to CREATE FUNCTION (created before 17.6.1.111 / 15.14.1.111) and issue_pg_cron_access scoped to CREATE SCHEMA (created before 15.1.0.130), while the grant functions they invoke were since updated fleet-wide and only act on CREATE EXTENSION events. With that mismatch, recreating the extensions during an upgrade never re-applies their wiring: graphql_public.graphql is left as the "not enabled" placeholder and the postgres role's cron grants are skipped.

How the mismatch crept in:

  • chore: Add migrations script to postgres AMI #329 seeded issue_pg_cron_access on CREATE SCHEMA (2022); the pg_graphql trigger was likewise seeded on CREATE FUNCTION
  • fix: pg_cron perms #780 (pg_cron, first shipped in 15.1.0.130) and the April pg_graphql migration 20260421000001 (first shipped in 17.6.1.111 / 15.14.1.111) rescoped trigger + function together — but migrations only run at image build, so existing projects kept the old triggers
  • supabase/salt#807 and supabase/salt#847 then replaced only the grant functions fleet-wide with the CREATE EXTENSION-scoped bodies, leaving old projects with a trigger that fires on events the new functions ignore
  • [GEN-7585] chore: patch pg_cron perms post-pg_upgrade #858 added the pg_cron drop/recreate to complete.sh, which (like the pg_graphql disable/re-enable that was always part of pg_upgrade) now silently loses the wiring on those projects

This adds a rescope_extension_event_triggers helper to common.sh and calls it from two places:

  • initiate.sh, before the extensions are dropped — the rescoped triggers are carried into the new cluster by pg_upgrade, and the failure-path re-enable on the source instance is covered as well
  • complete.sh, before run_generated_sql recreates the extensions — safety net in case the source ran an older script bundle

Linear: PSQLEXT-1672

Old projects still have these event triggers scoped to CREATE FUNCTION /
CREATE SCHEMA while the fleet-updated grant functions only act on
CREATE EXTENSION events, so the post-upgrade extension recreation never
re-applies their wiring. Rescope in initiate.sh before the extensions are
dropped (the fixed triggers travel through pg_upgrade) and again in
complete.sh before the generated SQL runs, as a safety net.
@utkarash2991
utkarash2991 requested review from a team as code owners September 21, 2026 21:02
Comment thread ansible/files/admin_api_scripts/pg_upgrade_scripts/complete.sh Outdated
Comment thread ansible/files/admin_api_scripts/pg_upgrade_scripts/common.sh Outdated
Both instances download the same target-version script bundle, so the
older-bundle scenario the complete.sh safety net guarded against doesn't
occur in practice. Keep the single rescope in initiate.sh and wrap it in
retry, since it is fail-soft and a skipped rescope silently loses the
extension wiring.
@utkarash2991
utkarash2991 requested review from a team and mmlb September 22, 2026 14:29
Comment thread ansible/files/admin_api_scripts/pg_upgrade_scripts/common.sh Outdated
Comment thread ansible/files/admin_api_scripts/pg_upgrade_scripts/common.sh Outdated
@utkarash2991
utkarash2991 requested a review from mmlb September 22, 2026 16:26

@mmlb mmlb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM.

Comment thread ansible/files/admin_api_scripts/pg_upgrade_scripts/common.sh
@utkarash2991
utkarash2991 added this pull request to the merge queue Sep 25, 2026
Merged via the queue into develop with commit ff04e12 Sep 25, 2026
45 of 46 checks passed
@utkarash2991
utkarash2991 deleted the utkarashsingh/pg-graphql-trigger-rescope-upgrade branch September 25, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants