Skip to content

Commit

Permalink
Revoke REPLICATION (#7052)
Browse files Browse the repository at this point in the history
## Problem
Currently users can cause problems with replication
## Summary of changes
Don't let them replicate
  • Loading branch information
Sasha Krassovsky committed Mar 8, 2024
1 parent 86e8c43 commit 4834d22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions compute_tools/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ pub fn handle_roles(spec: &ComputeSpec, client: &mut Client) -> Result<()> {
RoleAction::Create => {
// This branch only runs when roles are created through the console, so it is
// safe to add more permissions here. BYPASSRLS and REPLICATION are inherited
// from neon_superuser.
// from neon_superuser. (NOTE: REPLICATION has been removed from here for now).
let mut query: String = format!(
"CREATE ROLE {} INHERIT CREATEROLE CREATEDB BYPASSRLS REPLICATION IN ROLE neon_superuser",
"CREATE ROLE {} INHERIT CREATEROLE CREATEDB BYPASSRLS IN ROLE neon_superuser",
name.pg_quote()
);
info!("running role create query: '{}'", &query);
Expand Down Expand Up @@ -805,6 +805,18 @@ $$;"#,
"",
"",
// Add new migrations below.
r#"
DO $$
DECLARE
role_name TEXT;
BEGIN
FOR role_name IN SELECT rolname FROM pg_roles WHERE rolreplication IS TRUE
LOOP
RAISE NOTICE 'EXECUTING ALTER ROLE % NOREPLICATION', quote_ident(role_name);
EXECUTE 'ALTER ROLE ' || quote_ident(role_name) || ' NOREPLICATION';
END LOOP;
END
$$;"#,
];

let mut query = "CREATE SCHEMA IF NOT EXISTS neon_migration";
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 @@ -15,7 +15,7 @@ def test_migrations(neon_simple_env: NeonEnv):

endpoint.wait_for_migrations()

num_migrations = 8
num_migrations = 9

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

1 comment on commit 4834d22

@github-actions
Copy link

Choose a reason for hiding this comment

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

2576 tests run: 2440 passed, 0 failed, 136 skipped (full report)


Flaky tests (4)

Postgres 15

  • test_no_config[None]: debug
  • test_fully_custom_config: debug
  • test_null_config: debug

Postgres 14

  • test_timeline_deletion_with_files_stuck_in_upload_queue: release

Code coverage* (full report)

  • functions: 28.8% (7036 of 24438 functions)
  • lines: 47.6% (43457 of 91334 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
4834d22 at 2024-03-08T23:26:56.351Z :recycle:

Please sign in to comment.