diff --git a/releasenotes/notes/fix-postgres-pg-rewind-6eef0afb568439ce.yaml b/releasenotes/notes/fix-postgres-pg-rewind-6eef0afb568439ce.yaml new file mode 100644 index 0000000000..980ec567e9 --- /dev/null +++ b/releasenotes/notes/fix-postgres-pg-rewind-6eef0afb568439ce.yaml @@ -0,0 +1,2 @@ +fixes: + - Fix Postgresql promote (bug 1633515). diff --git a/trove/guestagent/strategies/replication/experimental/postgresql_impl.py b/trove/guestagent/strategies/replication/experimental/postgresql_impl.py index e0b1e3a1f6..855b48fb9b 100644 --- a/trove/guestagent/strategies/replication/experimental/postgresql_impl.py +++ b/trove/guestagent/strategies/replication/experimental/postgresql_impl.py @@ -143,7 +143,8 @@ class PostgresqlReplicationStreaming(base.Replication): repl_user = models.PostgreSQLUser(name=REPL_USER, password=pw) admin._create_user(context=None, user=repl_user) - admin.alter_user(None, repl_user, True, 'REPLICATION', 'LOGIN') + admin.alter_user(None, repl_user, True, + 'REPLICATION', 'SUPERUSER', 'LOGIN') return pw @@ -219,8 +220,8 @@ class PostgresqlReplicationStreaming(base.Replication): tmprec = "/tmp/recovery.conf.bak" operating_system.move(rec, tmprec, as_root=True) - cmd_full = " ".join(["pg_rewind", "-D", service.pgsql_data_dir, - '--source-pgdata=' + service.pgsql_data_dir, + cmd_full = " ".join(["pg_rewind", + '--target-pgdata=' + service.pgsql_data_dir, '--source-server=' + conninfo]) out, err = utils.execute("sudo", "su", "-", service.pgsql_owner, "-c", "%s" % cmd_full, check_exit_code=0)