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
This commit is contained in:
Petr Malik 2016-10-09 13:07:24 -04:00
parent 4bedc8b6e0
commit 16bae26001
2 changed files with 6 additions and 3 deletions

View File

@ -0,0 +1,2 @@
fixes:
- Fix Postgresql promote (bug 1633515).

View File

@ -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)