← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stub/launchpad/db-deploy into lp:launchpad

 

Stuart Bishop has proposed merging lp:~stub/launchpad/db-deploy into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #906222 in Launchpad itself: "More BAD_USERS creating false positives during fast downtime updates"
  https://bugs.launchpad.net/launchpad/+bug/906222
  Bug #911417 in Launchpad itself: "Staging db restore fails on make -C database/replication stagingsetup"
  https://bugs.launchpad.net/launchpad/+bug/911417
  Bug #1025396 in Launchpad itself: "deployment scripts need to cope with streaming replication"
  https://bugs.launchpad.net/launchpad/+bug/1025396
  Bug #1025399 in Launchpad itself: "full-update.py should wait for streaming slaves before completing"
  https://bugs.launchpad.net/launchpad/+bug/1025399

For more details, see:
https://code.launchpad.net/~stub/launchpad/db-deploy/+merge/116234

= Summary =

Rollout scripts fail as they don't cope with the SSO databases, still running PG 8.4

== Proposed fix ==

Only check for streaming replication lag on nodes running PG 9.1.

== Pre-implementation notes ==

Streaming replication isn't possible on the 8.4 nodes, so no loss.

== LOC Rationale ==

== Implementation details ==

== Tests ==

== Demo and Q/A ==


= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  database/schema/preflight.py

./database/schema/preflight.py
      14: '_pythonpath' imported but unused
-- 
https://code.launchpad.net/~stub/launchpad/db-deploy/+merge/116234
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stub/launchpad/db-deploy into lp:launchpad.
=== modified file 'database/schema/preflight.py'
--- database/schema/preflight.py	2012-07-19 14:55:40 +0000
+++ database/schema/preflight.py	2012-07-23 10:19:26 +0000
@@ -292,14 +292,21 @@
             max_lag = timedelta(seconds=-1)
             for node in self.nodes:
                 cur = node.con.cursor()
+                # streaming replication only works with 9.1 or later.
+                # Remove this guard when SSO nodes are migrated to 9.1.
                 cur.execute("""
-                    SELECT current_setting('hot_standby') = 'on',
-                    now() - pg_last_xact_replay_timestamp()
+                    select current_setting('server_version') >= '9.1'
                     """)
-                is_standby, lag = cur.fetchone()
-                if is_standby:
-                    self.log.debug2('streaming lag %s', lag)
-                    max_lag = max(max_lag, lag)
+                is_pg91 = cur.fetchone()[0]
+                if is_pg91:
+                    cur.execute("""
+                        SELECT current_setting('hot_standby') = 'on',
+                        now() - pg_last_xact_replay_timestamp()
+                        """)
+                    is_standby, lag = cur.fetchone()
+                    if is_standby:
+                        self.log.debug2('streaming lag %s', lag)
+                        max_lag = max(max_lag, lag)
             if max_lag < MAX_LAG:
                 break
             time.sleep(0.2)


Follow ups