Robert Collins has proposed merging lp:~lifeless/launchpad/bug-421901 into lp:launchpad/db-devel.
Requested reviews: Launchpad code reviewers (launchpad-reviewers) Related bugs: Bug #421901 in Launchpad itself: "Person:+bugs timeouts" https://bugs.launchpad.net/launchpad/+bug/421901 For more details, see: https://code.launchpad.net/~lifeless/launchpad/bug-421901/+merge/56861 Add a migration task for the denormalisation into BugMessage.owner. This completes the work we can sensibly do until the next database downtime window. -- https://code.launchpad.net/~lifeless/launchpad/bug-421901/+merge/56861 Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/launchpad/bug-421901 into lp:launchpad/db-devel.
=== modified file 'database/sampledata/current-dev.sql' --- database/sampledata/current-dev.sql 2011-03-30 10:46:24 +0000 +++ database/sampledata/current-dev.sql 2011-04-08 00:31:01 +0000 @@ -3403,42 +3403,42 @@ ALTER TABLE bugmessage DISABLE TRIGGER ALL; -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (1, 2, 1, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (2, 1, 3, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (3, 1, 4, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (4, 2, 5, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (5, 2, 6, NULL, NULL, 2); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (6, 4, 7, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (7, 5, 8, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (8, 6, 9, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (9, 3, 10, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (10, 7, 11, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (11, 8, 14, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (12, 9, 15, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (13, 10, 17, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (14, 10, 16, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (15, 11, 24, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (16, 11, 25, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (17, 11, 26, NULL, NULL, 2); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (18, 11, 27, NULL, NULL, 3); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (19, 11, 28, NULL, NULL, 4); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (20, 11, 29, NULL, NULL, 5); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (21, 11, 30, NULL, NULL, 6); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (22, 12, 31, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (23, 12, 33, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (24, 12, 34, NULL, NULL, 2); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (25, 12, 35, NULL, NULL, 3); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (26, 12, 36, NULL, NULL, 4); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (27, 13, 37, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (28, 13, 38, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (29, 14, 39, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (30, 15, 40, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (31, 15, 44, 11, '<[email protected]>', 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (32, 15, 45, 11, '<[email protected]>', 2); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (33, 15, 46, 11, '<[email protected]>', 3); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (34, 15, 47, 11, '<[email protected]>', 4); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (35, 15, 48, 11, '<[email protected]>', 5); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (36, 15, 49, 11, '<[email protected]>', 6); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (1, 2, 1, NULL, NULL, 0, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (2, 1, 3, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (3, 1, 4, NULL, NULL, 1, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (4, 2, 5, NULL, NULL, 1, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (5, 2, 6, NULL, NULL, 2, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (6, 4, 7, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (7, 5, 8, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (8, 6, 9, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (9, 3, 10, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (10, 7, 11, NULL, NULL, 0, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (11, 8, 14, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (12, 9, 15, NULL, NULL, 0, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (13, 10, 17, NULL, NULL, 0, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (14, 10, 16, NULL, NULL, 1, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (15, 11, 24, NULL, NULL, 0, 26); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (16, 11, 25, NULL, NULL, 1, 50); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (17, 11, 26, NULL, NULL, 2, 66); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (18, 11, 27, NULL, NULL, 3, 63); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (19, 11, 28, NULL, NULL, 4, 27); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (20, 11, 29, NULL, NULL, 5, 33); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (21, 11, 30, NULL, NULL, 6, 3); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (22, 12, 31, NULL, NULL, 0, 8); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (23, 12, 33, NULL, NULL, 1, 45); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (24, 12, 34, NULL, NULL, 2, 13); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (25, 12, 35, NULL, NULL, 3, 9); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (26, 12, 36, NULL, NULL, 4, 6); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (27, 13, 37, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (28, 13, 38, NULL, NULL, 1, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (29, 14, 39, NULL, NULL, 0, 63); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (30, 15, 40, NULL, NULL, 0, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (31, 15, 44, 11, '<[email protected]>', 1, 243614); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (32, 15, 45, 11, '<[email protected]>', 2, 243615); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (33, 15, 46, 11, '<[email protected]>', 3, 243614); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (34, 15, 47, 11, '<[email protected]>', 4, 243615); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (35, 15, 48, 11, '<[email protected]>', 5, 243616); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (36, 15, 49, 11, '<[email protected]>', 6, 243614); ALTER TABLE bugmessage ENABLE TRIGGER ALL; === modified file 'database/sampledata/current.sql' --- database/sampledata/current.sql 2011-03-18 15:28:46 +0000 +++ database/sampledata/current.sql 2011-04-08 00:31:01 +0000 @@ -3342,42 +3342,42 @@ ALTER TABLE bugmessage DISABLE TRIGGER ALL; -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (1, 2, 1, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (2, 1, 3, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (3, 1, 4, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (4, 2, 5, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (5, 2, 6, NULL, NULL, 2); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (6, 4, 7, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (7, 5, 8, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (8, 6, 9, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (9, 3, 10, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (10, 7, 11, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (11, 8, 14, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (12, 9, 15, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (13, 10, 17, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (14, 10, 16, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (15, 11, 24, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (16, 11, 25, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (17, 11, 26, NULL, NULL, 2); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (18, 11, 27, NULL, NULL, 3); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (19, 11, 28, NULL, NULL, 4); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (20, 11, 29, NULL, NULL, 5); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (21, 11, 30, NULL, NULL, 6); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (22, 12, 31, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (23, 12, 33, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (24, 12, 34, NULL, NULL, 2); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (25, 12, 35, NULL, NULL, 3); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (26, 12, 36, NULL, NULL, 4); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (27, 13, 37, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (28, 13, 38, NULL, NULL, 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (29, 14, 39, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (30, 15, 40, NULL, NULL, 0); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (31, 15, 44, 11, '<[email protected]>', 1); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (32, 15, 45, 11, '<[email protected]>', 2); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (33, 15, 46, 11, '<[email protected]>', 3); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (34, 15, 47, 11, '<[email protected]>', 4); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (35, 15, 48, 11, '<[email protected]>', 5); -INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (36, 15, 49, 11, '<[email protected]>', 6); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (1, 2, 1, NULL, NULL, 0, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (2, 1, 3, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (3, 1, 4, NULL, NULL, 1, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (4, 2, 5, NULL, NULL, 1, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (5, 2, 6, NULL, NULL, 2, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (6, 4, 7, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (7, 5, 8, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (8, 6, 9, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (9, 3, 10, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (10, 7, 11, NULL, NULL, 0, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (11, 8, 14, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (12, 9, 15, NULL, NULL, 0, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (13, 10, 17, NULL, NULL, 0, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (14, 10, 16, NULL, NULL, 1, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (15, 11, 24, NULL, NULL, 0, 26); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (16, 11, 25, NULL, NULL, 1, 50); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (17, 11, 26, NULL, NULL, 2, 66); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (18, 11, 27, NULL, NULL, 3, 63); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (19, 11, 28, NULL, NULL, 4, 27); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (20, 11, 29, NULL, NULL, 5, 33); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (21, 11, 30, NULL, NULL, 6, 3); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (22, 12, 31, NULL, NULL, 0, 8); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (23, 12, 33, NULL, NULL, 1, 45); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (24, 12, 34, NULL, NULL, 2, 13); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (25, 12, 35, NULL, NULL, 3, 9); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (26, 12, 36, NULL, NULL, 4, 6); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (27, 13, 37, NULL, NULL, 0, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (28, 13, 38, NULL, NULL, 1, 12); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (29, 14, 39, NULL, NULL, 0, 63); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (30, 15, 40, NULL, NULL, 0, 16); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (31, 15, 44, 11, '<[email protected]>', 1, 243614); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (32, 15, 45, 11, '<[email protected]>', 2, 243615); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (33, 15, 46, 11, '<[email protected]>', 3, 243614); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (34, 15, 47, 11, '<[email protected]>', 4, 243615); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (35, 15, 48, 11, '<[email protected]>', 5, 243616); +INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (36, 15, 49, 11, '<[email protected]>', 6, 243614); ALTER TABLE bugmessage ENABLE TRIGGER ALL; === modified file 'lib/lp/bugs/interfaces/bugmessage.py' --- lib/lp/bugs/interfaces/bugmessage.py 2011-03-02 15:34:31 +0000 +++ lib/lp/bugs/interfaces/bugmessage.py 2011-04-08 00:31:01 +0000 @@ -31,6 +31,7 @@ from lp.app.validators.attachment import attachment_size_constraint from lp.bugs.interfaces.bug import IBug from lp.bugs.interfaces.bugwatch import IBugWatch +from lp.registry.interfaces.person import IPerson from lp.services.fields import Title @@ -52,6 +53,9 @@ bugwatchID = Int(title=u'The bugwatch id.', readonly=True) remote_comment_id = TextLine( title=u"The id this comment has in the bugwatch's bug tracker.") + ownerID = Attribute("The ID of the owner mirrored from the message") + owner = Object(schema=IPerson, + title=u"The Message owner mirrored from the message.", readonly=True) class IBugMessageSet(Interface): === modified file 'lib/lp/bugs/model/bugmessage.py' --- lib/lp/bugs/model/bugmessage.py 2011-03-02 15:34:31 +0000 +++ lib/lp/bugs/model/bugmessage.py 2011-04-08 00:31:01 +0000 @@ -29,6 +29,7 @@ IBugMessage, IBugMessageSet, ) +from lp.registry.interfaces.person import validate_public_person class BugMessage(SQLBase): @@ -46,6 +47,9 @@ remote_comment_id = StringCol(notNull=False, default=None) # -- The index of the message is cached in the DB. index = IntCol(notNull=True) + # -- The owner, cached from the message table using triggers. + owner = ForeignKey(dbName='owner', foreignKey='Person', + storm_validator=validate_public_person, notNull=False) def __repr__(self): return "<BugMessage at 0x%x message=%s index=%s>" % ( === modified file 'lib/lp/scripts/garbo.py' --- lib/lp/scripts/garbo.py 2011-03-31 20:55:25 +0000 +++ lib/lp/scripts/garbo.py 2011-04-08 00:31:01 +0000 @@ -64,6 +64,7 @@ from lp.bugs.interfaces.bug import IBugSet from lp.bugs.model.bug import Bug from lp.bugs.model.bugattachment import BugAttachment +from lp.bugs.model.bugmessage import BugMessage from lp.bugs.model.bugnotification import BugNotification from lp.bugs.model.bugwatch import BugWatchActivity from lp.bugs.scripts.checkwatches.scheduler import ( @@ -692,6 +693,36 @@ """ +class MirrorBugMessageOwner(TunableLoop): + """Mirror BugMessage.owner from Message. + + Only needed until they are all set, after that triggers will maintain it. + """ + + # Test migration did 3M in 2 hours, so 5000 is ~ 10 seconds - and thats the + # max we want to hold a DB lock open for. + minimum_chunk_size = 1000 + maximum_chunk_size = 5000 + + def __init__(self, log, abort_time=None): + super(MirrorBugMessageOwner, self).__init__(log, abort_time) + self.store = IMasterStore(BugMessage) + self.isDone = IMasterStore(BugMessage).find( + BugMessage, BugMessage.ownerID==None).is_empty + + def __call__(self, chunk_size): + """See `ITunableLoop`.""" + transaction.begin() + updated = self.store.execute("""update bugmessage set + owner=message.owner from message where + bugmessage.message=message.id and bugmessage.id in + (select id from bugmessage where owner is NULL limit %s);""" + % int(chunk_size) + ).rowcount + self.log.debug("Updated %s bugmessages." % updated) + transaction.commit() + + class BugHeatUpdater(TunableLoop): """A `TunableLoop` for bug heat calculations.""" @@ -1078,6 +1109,7 @@ class HourlyDatabaseGarbageCollector(BaseDatabaseGarbageCollector): script_name = 'garbo-hourly' tunable_loops = [ + MirrorBugMessageOwner, OAuthNoncePruner, OpenIDConsumerNoncePruner, OpenIDConsumerAssociationPruner, === modified file 'lib/lp/scripts/tests/test_garbo.py' --- lib/lp/scripts/tests/test_garbo.py 2011-03-31 20:55:25 +0000 +++ lib/lp/scripts/tests/test_garbo.py 2011-04-08 00:31:01 +0000 @@ -55,6 +55,7 @@ ZopelessDatabaseLayer, ) from lp.archiveuploader.dscfile import findFile +from lp.bugs.model.bugmessage import BugMessage from lp.bugs.model.bugnotification import ( BugNotification, BugNotificationRecipient, @@ -932,3 +933,23 @@ self.assertFalse(spr.changelog == None) self.assertTrue(spr.changelog.restricted) self.assertEqual(changelog, spr.changelog.read()) + + def test_mirror_bugmessages(self): + # Nuke the owner in sampledata. + con = DatabaseLayer._db_fixture.root_connection() + try: + cur = con.cursor() + cur.execute("ALTER TABLE bugmessage " + "DISABLE TRIGGER bugmessage__owner__mirror") + cur.execute("UPDATE bugmessage set owner=NULL") + cur.execute("ALTER TABLE bugmessage " + "ENABLE TRIGGER bugmessage__owner__mirror") + con.commit() + finally: + con.close() + store = IMasterStore(BugMessage) + unmigrated = store.find(BugMessage, BugMessage.ownerID==None).count + self.assertNotEqual(0, unmigrated()) + self.runHourly() + self.assertEqual(0, unmigrated()) + === modified file 'lib/lp/testing/pgsql.py' --- lib/lp/testing/pgsql.py 2011-02-19 13:50:19 +0000 +++ lib/lp/testing/pgsql.py 2011-04-08 00:31:01 +0000 @@ -220,9 +220,14 @@ connection_parameters.append('port=%s' % self.host) return ' '.join(connection_parameters) + def root_connection(self, dbname=None): + if dbname is None: + dbname = self.dbname + return psycopg2.connect(self._connectionString(dbname)) + def generateResetSequencesSQL(self): """Return a SQL statement that resets all sequences.""" - con = psycopg2.connect(self._connectionString(self.dbname)) + con = self.root_connection() cur = con.cursor() try: return generateResetSequencesSQL(cur) @@ -243,7 +248,7 @@ # anyway (because they might have been incremented even if # nothing was committed), making sure not to disturb the # 'committed' flag, and we're done. - con = psycopg2.connect(self._connectionString(self.dbname)) + con = self.root_connection() cur = con.cursor() if self.reset_sequences_sql is None: resetSequences(cur) @@ -261,7 +266,7 @@ # template database that are slow in dropping off. attempts = 60 for counter in range(0, attempts): - con = psycopg2.connect(self._connectionString(self.template)) + con = self.root_connection(self.template) try: con.set_isolation_level(0) cur = con.cursor() @@ -321,7 +326,7 @@ attempts = 100 for i in range(0, attempts): try: - con = psycopg2.connect(self._connectionString(self.template)) + con = self.root_connection(self.template) except psycopg2.OperationalError, x: if 'does not exist' in x: return
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : [email protected] Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp

