Merge lp:~cjwatson/launchpad/postgresql-10-more-replication into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18916
Proposed branch: lp:~cjwatson/launchpad/postgresql-10-more-replication
Merge into: lp:launchpad
Diff against target: 24 lines (+10/-4)
1 file modified
database/schema/dbcontroller.py (+10/-4)
To merge this branch: bzr merge lp:~cjwatson/launchpad/postgresql-10-more-replication
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+365074@code.launchpad.net

Commit message

Handle renaming of pg_stat_replication.replay_location to pg_stat_replication.replay_lsn in PostgreSQL 10.

Description of the change

Spotted in staging logs:

Traceback (most recent call last):
  File "./full-update.py", line 232, in <module>
    sys.exit(main())
  File "./full-update.py", line 116, in main
    if not NoConnectionCheckPreflight(log, controller).check_all():
  File "/srv/staging.launchpad.net/staging/launchpad/database/schema/preflight.py", line 313, in check_all
    if not self.replication_paused and not self.check_can_sync():
  File "/srv/staging.launchpad.net/staging/launchpad/database/schema/preflight.py", line 281, in check_can_sync
    streaming_success = streaming_sync(self.lpmain_master_node.con, 30)
  File "/srv/staging.launchpad.net/staging/launchpad/database/schema/dbcontroller.py", line 52, in streaming_sync
    """, (wal_point,))
psycopg2.ProgrammingError: column "replay_location" does not exist
LINE 3: WHERE replay_location < E'4B61/FF003210' LIMIT 1
                          ^

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-05 13:30:42 +0000
3+++ database/schema/dbcontroller.py 2019-03-25 21:18:51 +0000
4@@ -46,10 +46,16 @@
5 wal_point = cur.fetchone()[0]
6 start_time = time.time()
7 while timeout is None or time.time() < start_time + timeout:
8- cur.execute("""
9- SELECT FALSE FROM pg_stat_replication
10- WHERE replay_location < %s LIMIT 1
11- """, (wal_point,))
12+ if con.server_version >= 100000:
13+ cur.execute("""
14+ SELECT FALSE FROM pg_stat_replication
15+ WHERE replay_lsn < %s LIMIT 1
16+ """, (wal_point,))
17+ else:
18+ cur.execute("""
19+ SELECT FALSE FROM pg_stat_replication
20+ WHERE replay_location < %s LIMIT 1
21+ """, (wal_point,))
22 if cur.fetchone() is None:
23 # All slaves, possibly 0, are in sync.
24 return True