From 119ddf6ccf8c5a690af183c919de5b3b4daa3f43 Mon Sep 17 00:00:00 2001 From: Sasha Krassovsky Date: Thu, 11 Jul 2024 13:29:35 -0700 Subject: [PATCH] Grant execute on snapshot functions to neon_superuser (#8346) ## 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 --- ...nt_snapshot_synchronization_funcs_to_neon_superuser.sql | 7 +++++++ compute_tools/src/spec.rs | 3 +++ test_runner/regress/test_migrations.py | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 compute_tools/src/migrations/0009-grant_snapshot_synchronization_funcs_to_neon_superuser.sql diff --git a/compute_tools/src/migrations/0009-grant_snapshot_synchronization_funcs_to_neon_superuser.sql b/compute_tools/src/migrations/0009-grant_snapshot_synchronization_funcs_to_neon_superuser.sql new file mode 100644 index 0000000000..28750e00dd --- /dev/null +++ b/compute_tools/src/migrations/0009-grant_snapshot_synchronization_funcs_to_neon_superuser.sql @@ -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 $$; diff --git a/compute_tools/src/spec.rs b/compute_tools/src/spec.rs index 37090b08fd..1d12b88c7c 100644 --- a/compute_tools/src/spec.rs +++ b/compute_tools/src/spec.rs @@ -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()?; diff --git a/test_runner/regress/test_migrations.py b/test_runner/regress/test_migrations.py index 5637f160cf..91bd3ea50c 100644 --- a/test_runner/regress/test_migrations.py +++ b/test_runner/regress/test_migrations.py @@ -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")