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
  Bug #1036694 in Launchpad itself: "security.py still references slony"
  https://bugs.launchpad.net/launchpad/+bug/1036694

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

= Summary =

preflight.py was failing on production.

The the master had started in recovery mode, and the existing detection code 
treated it like a hot standby. It used to work, but we now have hot_standby=on 
everywhere to simplify config management (this setting is ignored unless the 
server is started up as a standby).

Also fix an explicit Python 2.6 shebang preventing me from testing this 
locally. This would have dated from when the production servers ran Hardy and 
the default Python was 2.5.

Also remove a guard condition that is no longer necessary, as we have 
PostgreSQL 9.1 everywhere.

== Proposed fix ==

== Pre-implementation notes ==

== 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/full-update.py

./database/schema/preflight.py
      14: '_pythonpath' imported but unused
./database/schema/full-update.py
       7: '_pythonpath' imported but unused
-- 
https://code.launchpad.net/~stub/launchpad/db-deploy/+merge/122003
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/full-update.py'
--- database/schema/full-update.py	2012-08-15 13:30:41 +0000
+++ database/schema/full-update.py	2012-08-30 08:02:19 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6 -S
+#!/usr/bin/python -S
 # Copyright 2011-2012 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 

=== modified file 'database/schema/preflight.py'
--- database/schema/preflight.py	2012-08-07 10:28:06 +0000
+++ database/schema/preflight.py	2012-08-30 08:02:19 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6 -S
+#!/usr/bin/python -S
 # Copyright 2011-2012 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
@@ -237,21 +237,15 @@
             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('server_version') >= '9.1'
+                    SELECT
+                        pg_is_in_recovery(),
+                        now() - pg_last_xact_replay_timestamp()
                     """)
-                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)
+                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)

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to