launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #23346
[Merge] lp:~cjwatson/launchpad/postgresql-10-replication into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/postgresql-10-replication into lp:launchpad with lp:~cjwatson/launchpad/postgresql-version-checks as a prerequisite.
Commit message:
Update replication machinery to cope with changes in PostgreSQL 10.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/postgresql-10-replication/+merge/363972
I don't have a setup that allows me to test any of this at the moment, so I'm flying somewhat blind.
I've left the 9.3/xlog reference in database/replication/Makefile alone. Precedent seems to be that we just update that once staging has been upgraded.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/postgresql-10-replication into lp:launchpad.
=== modified file 'database/replication/walblock.py'
--- database/replication/walblock.py 2014-01-13 07:38:24 +0000
+++ database/replication/walblock.py 2019-03-05 13:35:13 +0000
@@ -22,8 +22,8 @@
help="Block if there are more than N unshipped WAL files.", default=25)
parser.add_option(
"-d", dest="wal_dir", metavar="DIR", type="string",
- help="Path to pg_xlog directory",
- default="/var/lib/postgresql/9.1/main/pg_xlog")
+ help="Path to pg_wal directory",
+ default="/var/lib/postgresql/10/main/pg_wal")
parser.add_option(
"-v", "--verbose", action="store_true", default=False, help="Verbose")
options, args = parser.parse_args()
=== modified file 'database/schema/dbcontroller.py'
--- database/schema/dbcontroller.py 2012-09-28 06:15:58 +0000
+++ database/schema/dbcontroller.py 2019-03-05 13:35:13 +0000
@@ -39,7 +39,10 @@
cur = con.cursor()
# Force a WAL switch, returning the current position.
- cur.execute('SELECT pg_switch_xlog()')
+ if con.server_version >= 100000:
+ cur.execute('SELECT pg_switch_wal()')
+ else:
+ cur.execute('SELECT pg_switch_xlog()')
wal_point = cur.fetchone()[0]
start_time = time.time()
while timeout is None or time.time() < start_time + timeout:
@@ -103,7 +106,10 @@
try:
con = pg_connect(conn_str)
cur = con.cursor()
- cur.execute('select pg_xlog_replay_pause()')
+ if con.server_version >= 100000:
+ cur.execute('select pg_wal_replay_pause()')
+ else:
+ cur.execute('select pg_xlog_replay_pause()')
except psycopg2.Error, x:
self.log.error(
'Unable to pause replication to %s (%s).'
@@ -119,7 +125,10 @@
try:
con = pg_connect(conn_str)
cur = con.cursor()
- cur.execute('select pg_xlog_replay_resume()')
+ if con.server_version >= 100000:
+ cur.execute('select pg_wal_replay_resume()')
+ else:
+ cur.execute('select pg_xlog_replay_resume()')
except psycopg2.Error, x:
success = False
self.log.error(
@@ -140,11 +149,17 @@
try:
con = pg_connect(conn_str)
cur = con.cursor()
- cur.execute("SELECT pg_is_xlog_replay_paused()")
+ if con.server_version >= 100000:
+ cur.execute("SELECT pg_is_wal_replay_paused()")
+ else:
+ cur.execute("SELECT pg_is_xlog_replay_paused()")
replication_paused = cur.fetchone()[0]
if replication_paused:
self.log.warn("Replication paused on %s. Resuming.", name)
- cur.execute("SELECT pg_xlog_replay_resume()")
+ if con.server_version >= 100000:
+ cur.execute("SELECT pg_wal_replay_resume()")
+ else:
+ cur.execute("SELECT pg_xlog_replay_resume()")
wait_for_sync = True
except psycopg2.Error, x:
success = False
=== modified file 'database/schema/full-update.py'
--- database/schema/full-update.py 2012-10-12 11:49:37 +0000
+++ database/schema/full-update.py 2019-03-05 13:35:13 +0000
@@ -175,9 +175,14 @@
# Resume replication.
replication_paused = not controller.resume_replication()
if replication_paused:
- log.error(
- "Failed to resume replication. Run pg_xlog_replay_pause() "
- "on all slaves to manually resume.")
+ if master_con.server_version >= 100000:
+ log.error(
+ "Failed to resume replication. Run pg_wal_replay_pause() "
+ "on all slaves to manually resume.")
+ else:
+ log.error(
+ "Failed to resume replication. Run pg_xlog_replay_pause() "
+ "on all slaves to manually resume.")
else:
if controller.sync():
log.info('Slaves in sync. Updates replicated.')
Follow ups