Merge lp:~cjwatson/launchpad/remove-postgresql-9.x-support into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18923
Proposed branch: lp:~cjwatson/launchpad/remove-postgresql-9.x-support
Merge into: lp:launchpad
Diff against target: 126 lines (+15/-41)
4 files modified
database/schema/dbcontroller.py (+9/-30)
database/schema/full-update.py (+3/-8)
test_on_merge.py (+2/-2)
utilities/launchpad-database-setup (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/remove-postgresql-9.x-support
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+365845@code.launchpad.net

Commit message

Remove support for running on PostgreSQL < 10.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/schema/dbcontroller.py'
2--- database/schema/dbcontroller.py 2019-03-25 21:12:02 +0000
3+++ database/schema/dbcontroller.py 2019-04-11 09:41:09 +0000
4@@ -39,23 +39,14 @@
5 cur = con.cursor()
6
7 # Force a WAL switch, returning the current position.
8- if con.server_version >= 100000:
9- cur.execute('SELECT pg_switch_wal()')
10- else:
11- cur.execute('SELECT pg_switch_xlog()')
12+ cur.execute('SELECT pg_switch_wal()')
13 wal_point = cur.fetchone()[0]
14 start_time = time.time()
15 while timeout is None or time.time() < start_time + timeout:
16- if con.server_version >= 100000:
17- cur.execute("""
18- SELECT FALSE FROM pg_stat_replication
19- WHERE replay_lsn < %s LIMIT 1
20- """, (wal_point,))
21- else:
22- cur.execute("""
23- SELECT FALSE FROM pg_stat_replication
24- WHERE replay_location < %s LIMIT 1
25- """, (wal_point,))
26+ cur.execute("""
27+ SELECT FALSE FROM pg_stat_replication
28+ WHERE replay_lsn < %s LIMIT 1
29+ """, (wal_point,))
30 if cur.fetchone() is None:
31 # All slaves, possibly 0, are in sync.
32 return True
33@@ -112,10 +103,7 @@
34 try:
35 con = pg_connect(conn_str)
36 cur = con.cursor()
37- if con.server_version >= 100000:
38- cur.execute('select pg_wal_replay_pause()')
39- else:
40- cur.execute('select pg_xlog_replay_pause()')
41+ cur.execute('select pg_wal_replay_pause()')
42 except psycopg2.Error, x:
43 self.log.error(
44 'Unable to pause replication to %s (%s).'
45@@ -131,10 +119,7 @@
46 try:
47 con = pg_connect(conn_str)
48 cur = con.cursor()
49- if con.server_version >= 100000:
50- cur.execute('select pg_wal_replay_resume()')
51- else:
52- cur.execute('select pg_xlog_replay_resume()')
53+ cur.execute('select pg_wal_replay_resume()')
54 except psycopg2.Error, x:
55 success = False
56 self.log.error(
57@@ -155,17 +140,11 @@
58 try:
59 con = pg_connect(conn_str)
60 cur = con.cursor()
61- if con.server_version >= 100000:
62- cur.execute("SELECT pg_is_wal_replay_paused()")
63- else:
64- cur.execute("SELECT pg_is_xlog_replay_paused()")
65+ cur.execute("SELECT pg_is_wal_replay_paused()")
66 replication_paused = cur.fetchone()[0]
67 if replication_paused:
68 self.log.warn("Replication paused on %s. Resuming.", name)
69- if con.server_version >= 100000:
70- cur.execute("SELECT pg_wal_replay_resume()")
71- else:
72- cur.execute("SELECT pg_xlog_replay_resume()")
73+ cur.execute("SELECT pg_wal_replay_resume()")
74 wait_for_sync = True
75 except psycopg2.Error, x:
76 success = False
77
78=== modified file 'database/schema/full-update.py'
79--- database/schema/full-update.py 2019-03-05 13:30:42 +0000
80+++ database/schema/full-update.py 2019-04-11 09:41:09 +0000
81@@ -175,14 +175,9 @@
82 # Resume replication.
83 replication_paused = not controller.resume_replication()
84 if replication_paused:
85- if master_con.server_version >= 100000:
86- log.error(
87- "Failed to resume replication. Run pg_wal_replay_pause() "
88- "on all slaves to manually resume.")
89- else:
90- log.error(
91- "Failed to resume replication. Run pg_xlog_replay_pause() "
92- "on all slaves to manually resume.")
93+ log.error(
94+ "Failed to resume replication. Run pg_wal_replay_pause() "
95+ "on all slaves to manually resume.")
96 else:
97 if controller.sync():
98 log.info('Slaves in sync. Updates replicated.')
99
100=== modified file 'test_on_merge.py'
101--- test_on_merge.py 2019-03-05 13:03:45 +0000
102+++ test_on_merge.py 2019-04-11 09:41:09 +0000
103@@ -60,8 +60,8 @@
104 # Sanity check PostgreSQL version. No point in trying to create a test
105 # database when PostgreSQL is too old.
106 con = psycopg2.connect('dbname=template1')
107- if con.server_version < 90300:
108- print 'Your PostgreSQL version is too old. You need at least 9.3.x'
109+ if con.server_version < 100000:
110+ print 'Your PostgreSQL version is too old. You need at least 10.x'
111 print 'You have %s' % con.get_parameter_status('server_version')
112 return 1
113
114
115=== modified file 'utilities/launchpad-database-setup'
116--- utilities/launchpad-database-setup 2019-03-05 13:36:18 +0000
117+++ utilities/launchpad-database-setup 2019-04-11 09:41:09 +0000
118@@ -19,7 +19,7 @@
119 # initial Launchpad setup on an otherwise unconfigured postgresql instance
120
121 pgversion=
122-for try_pgversion in 9.3 9.5 9.6 10
123+for try_pgversion in 10
124 do
125 sudo grep -qs "^auto" /etc/postgresql/$try_pgversion/main/start.conf
126 if [ $? -eq 0 ]; then