Merge lp:~stub/launchpad/pending-db-changes into lp:launchpad/db-devel

Proposed by Stuart Bishop
Status: Merged
Approved by: Stuart Bishop
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~stub/launchpad/pending-db-changes
Merge into: lp:launchpad/db-devel
Diff against target: 118 lines (+20/-12)
6 files modified
database/replication/helpers.py (+1/-1)
database/replication/initialize.py (+3/-3)
database/replication/repair-restored-db.py (+1/-1)
database/schema/patch-2207-21-0.sql (+2/-1)
database/schema/patch-2207-27-0.sql (+1/-1)
lib/canonical/database/sqlbase.py (+12/-5)
To merge this branch: bzr merge lp:~stub/launchpad/pending-db-changes
Reviewer Review Type Date Requested Status
Paul Hummer (community) code Approve
Review via email: mp+17872@code.launchpad.net

Commit message

Repair staging and replication scripts.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

We recently refactored read-only mode, which broke our staging and replication scripts due to config changes and removal of a helper.

Revision history for this message
Paul Hummer (rockstar) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'database/replication/helpers.py'
--- database/replication/helpers.py 2010-01-08 05:15:13 +0000
+++ database/replication/helpers.py 2010-01-22 10:21:20 +0000
@@ -287,7 +287,7 @@
287 assert len(node_ids) == 1, "Multiple nodes but no paths."287 assert len(node_ids) == 1, "Multiple nodes but no paths."
288 master_node_id = node_ids[0]288 master_node_id = node_ids[0]
289 master_connection_string = ConnectionString(289 master_connection_string = ConnectionString(
290 config.database.main_master)290 config.database.rw_main_master)
291 master_connection_string.user = 'slony'291 master_connection_string.user = 'slony'
292 return [Node(292 return [Node(
293 master_node_id, 'node%d_node' % master_node_id,293 master_node_id, 'node%d_node' % master_node_id,
294294
=== modified file 'database/replication/initialize.py'
--- database/replication/initialize.py 2010-01-06 13:53:16 +0000
+++ database/replication/initialize.py 2010-01-22 10:21:20 +0000
@@ -41,9 +41,9 @@
41 """Duplicate the master schema into the slaves."""41 """Duplicate the master schema into the slaves."""
42 log.info('Duplicating database schema')42 log.info('Duplicating database schema')
4343
44 master_cs = ConnectionString(config.database.main_master)44 master_cs = ConnectionString(config.database.rw_main_master)
45 master_cs.user = options.dbuser45 master_cs.user = options.dbuser
46 slave1_cs = ConnectionString(config.database.main_slave)46 slave1_cs = ConnectionString(config.database.rw_main_slave)
47 slave1_cs.user = options.dbuser47 slave1_cs.user = options.dbuser
4848
49 # We can't use pg_dump to replicate security as not all of the roles49 # We can't use pg_dump to replicate security as not all of the roles
@@ -70,7 +70,7 @@
70 """Initialize the cluster."""70 """Initialize the cluster."""
71 log.info('Initializing Slony-I cluster')71 log.info('Initializing Slony-I cluster')
72 master_connection_string = ConnectionString(72 master_connection_string = ConnectionString(
73 config.database.main_master)73 config.database.rw_main_master)
74 master_connection_string.user = 'slony'74 master_connection_string.user = 'slony'
75 helpers.execute_slonik("""75 helpers.execute_slonik("""
76 node 1 admin conninfo = '%s';76 node 1 admin conninfo = '%s';
7777
=== modified file 'database/replication/repair-restored-db.py'
--- database/replication/repair-restored-db.py 2009-11-18 03:46:31 +0000
+++ database/replication/repair-restored-db.py 2010-01-22 10:21:20 +0000
@@ -86,7 +86,7 @@
86 log.debug('Broken or no Slony-I install.')86 log.debug('Broken or no Slony-I install.')
87 return False87 return False
8888
89 connection_string = ConnectionString(config.database.main_master)89 connection_string = ConnectionString(config.database.rw_main_master)
90 if options.dbname:90 if options.dbname:
91 connection_string.dbname = options.dbname91 connection_string.dbname = options.dbname
92 if options.dbuser:92 if options.dbuser:
9393
=== modified file 'database/schema/patch-2207-21-0.sql'
--- database/schema/patch-2207-21-0.sql 2010-01-04 04:48:37 +0000
+++ database/schema/patch-2207-21-0.sql 2010-01-22 10:21:20 +0000
@@ -3,6 +3,7 @@
3ALTER TABLE Language ALTER englishname SET NOT NULL;3ALTER TABLE Language ALTER englishname SET NOT NULL;
44
5ALTER TABLE LibraryFileContent ALTER filesize TYPE bigint;5ALTER TABLE LibraryFileContent ALTER filesize TYPE bigint;
6CLUSTER LibraryFileContent USING libraryfilecontent_pkey; -- repack6-- Do later - too much downtime this cycle.
7--CLUSTER LibraryFileContent USING libraryfilecontent_pkey; -- repack
78
8INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 21, 0);9INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 21, 0);
910
=== modified file 'database/schema/patch-2207-27-0.sql'
--- database/schema/patch-2207-27-0.sql 2010-01-19 15:51:48 +0000
+++ database/schema/patch-2207-27-0.sql 2010-01-22 10:21:20 +0000
@@ -4,7 +4,7 @@
4SET client_min_messages TO ERROR;4SET client_min_messages TO ERROR;
55
6DROP INDEX bug__hotness__idx;6DROP INDEX bug__hotness__idx;
7ALTER table bug ADD COLUMN heat_last_updated timestamp;7ALTER table bug ADD COLUMN heat_last_updated timestamp without time zone;
8ALTER table bug RENAME COLUMN hotness to heat;8ALTER table bug RENAME COLUMN hotness to heat;
9ALTER table bugtask RENAME COLUMN hotness_rank to heat_rank;9ALTER table bugtask RENAME COLUMN hotness_rank to heat_rank;
10CREATE INDEX bug__heat_last_updated__idx ON bug USING btree (heat_last_updated);10CREATE INDEX bug__heat_last_updated__idx ON bug USING btree (heat_last_updated);
1111
=== modified file 'lib/canonical/database/sqlbase.py'
--- lib/canonical/database/sqlbase.py 2010-01-13 20:06:09 +0000
+++ lib/canonical/database/sqlbase.py 2010-01-22 10:21:20 +0000
@@ -7,7 +7,6 @@
7from datetime import datetime7from datetime import datetime
8import re8import re
9from textwrap import dedent9from textwrap import dedent
10
11import psycopg210import psycopg2
12from psycopg2.extensions import (11from psycopg2.extensions import (
13 ISOLATION_LEVEL_AUTOCOMMIT, ISOLATION_LEVEL_READ_COMMITTED,12 ISOLATION_LEVEL_AUTOCOMMIT, ISOLATION_LEVEL_READ_COMMITTED,
@@ -758,6 +757,17 @@
758757
759 Default database name is the one specified in the main configuration file.758 Default database name is the one specified in the main configuration file.
760 """759 """
760 con = psycopg2.connect(connect_string(user, dbname))
761 con.set_isolation_level(isolation)
762 return con
763
764
765def connect_string(user, dbname=None):
766 """Return a PostgreSQL connection string.
767
768 Allows you to pass the generated connection details to external
769 programs like pg_dump or embed in slonik scripts.
770 """
761 from canonical import lp771 from canonical import lp
762 # We start with the config string from the config file, and overwrite772 # We start with the config string from the config file, and overwrite
763 # with the passed in dbname or modifications made by db_options()773 # with the passed in dbname or modifications made by db_options()
@@ -780,10 +790,7 @@
780 con_str_overrides.append('dbname=%s' % dbname)790 con_str_overrides.append('dbname=%s' % dbname)
781791
782 con_str = ' '.join([con_str] + con_str_overrides)792 con_str = ' '.join([con_str] + con_str_overrides)
783793 return con_str
784 con = psycopg2.connect(con_str)
785 con.set_isolation_level(isolation)
786 return con
787794
788795
789class cursor:796class cursor:

Subscribers

People subscribed via source and target branches

to status/vote changes: