Skip to content

Commit

Permalink
Grant execute on snapshot functions to neon_superuser (#8346)
Browse files Browse the repository at this point in the history
## Problem
I need `neon_superuser` to be allowed to create snapshots for
replication tests

## Summary of changes
Adds a migration that grants these functions to neon_superuser
  • Loading branch information
Sasha Krassovsky authored and skyzh committed Jul 15, 2024
1 parent 90f447b commit 119ddf6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DO $$
BEGIN
IF (SELECT setting::numeric >= 160000 FROM pg_settings WHERE name = 'server_version_num') THEN
EXECUTE 'GRANT EXECUTE ON FUNCTION pg_export_snapshot TO neon_superuser';
EXECUTE 'GRANT EXECUTE ON FUNCTION pg_log_standby_snapshot TO neon_superuser';
END IF;
END $$;
3 changes: 3 additions & 0 deletions compute_tools/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,9 @@ pub fn handle_migrations(client: &mut Client) -> Result<()> {
"./migrations/0007-grant_all_on_sequences_to_neon_superuser_with_grant_option.sql"
),
include_str!("./migrations/0008-revoke_replication_for_previously_allowed_roles.sql"),
include_str!(
"./migrations/0009-grant_snapshot_synchronization_funcs_to_neon_superuser.sql"
),
];

MigrationRunner::new(client, &migrations).run_migrations()?;
Expand Down
2 changes: 1 addition & 1 deletion test_runner/regress/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_migrations(neon_simple_env: NeonEnv):

endpoint.wait_for_migrations()

num_migrations = 9
num_migrations = 10

with endpoint.cursor() as cur:
cur.execute("SELECT id FROM neon_migration.migration_id")
Expand Down

0 comments on commit 119ddf6

Please sign in to comment.