From 16bae26001c68aff69f64967c3c4665af4611bbe Mon Sep 17 00:00:00 2001 From: Petr Malik Date: Sun, 9 Oct 2016 13:07:24 -0400 Subject: [PATCH] Fix Postgresql pg_rewind call Removed an extra 'source-pgdata' argument and replaced '-D' with more verbose version of the same flag. Give the replicator user superaccess. Change-Id: Id8e3eefad60666e73c029a03ce59e765d390e908 Closes-Bug: 1633515 --- .../notes/fix-postgres-pg-rewind-6eef0afb568439ce.yaml | 2 ++ .../strategies/replication/experimental/postgresql_impl.py | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/fix-postgres-pg-rewind-6eef0afb568439ce.yaml 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)