~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to database/schema/preflight.py

  • Committer: Stuart Bishop
  • Date: 2011-07-25 13:59:01 UTC
  • mto: (7675.1045.660 db-devel)
  • mto: This revision was merged to the branch mainline in revision 13516.
  • Revision ID: stuart.bishop@canonical.com-20110725135901-3dj9ybsvlngsnv25
delint

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
FRAGILE_USERS = frozenset(['archivepublisher'])
45
45
 
46
46
# How lagged the cluster can be before failing the preflight check.
47
 
MAX_LAG = timedelta(seconds=45)
 
47
MAX_LAG = timedelta(seconds=60)
48
48
 
49
49
 
50
50
class DatabasePreflight:
201
201
        # Check replication lag on every node just in case there are
202
202
        # disagreements.
203
203
        max_lag = timedelta(seconds=-1)
204
 
        max_lag_node = None
205
204
        for node in self.nodes:
206
205
            cur = node.con.cursor()
207
206
            cur.execute("""
211
210
            dbname, lag = cur.fetchone()
212
211
            if lag > max_lag:
213
212
                max_lag = lag
214
 
                max_lag_node = node
215
213
            self.log.debug(
216
214
                "%s reports database lag of %s.", dbname, lag)
217
215
        if max_lag <= MAX_LAG:
287
285
        for node in self.lpmain_nodes:
288
286
            cur = node.con.cursor()
289
287
            cur.execute("""
290
 
                SELECT procpid, datname, usename, pg_terminate_backend(procpid)
 
288
                SELECT
 
289
                    procpid, datname, usename, pg_terminate_backend(procpid)
291
290
                FROM pg_stat_activity
292
291
                WHERE
293
292
                    datname=current_database()