Merge lp:~lifeless/launchpad/bug-421901 into lp:launchpad/db-devel

Proposed by Robert Collins
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: 10416
Proposed branch: lp:~lifeless/launchpad/bug-421901
Merge into: lp:launchpad/db-devel
Diff against target: 349 lines (+142/-76)
7 files modified
database/sampledata/current-dev.sql (+36/-36)
database/sampledata/current.sql (+36/-36)
lib/lp/bugs/interfaces/bugmessage.py (+4/-0)
lib/lp/bugs/model/bugmessage.py (+4/-0)
lib/lp/scripts/garbo.py (+32/-0)
lib/lp/scripts/tests/test_garbo.py (+21/-0)
lib/lp/testing/pgsql.py (+9/-4)
To merge this branch: bzr merge lp:~lifeless/launchpad/bug-421901
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+56861@code.launchpad.net

Commit message

[r=mwhudson][bug=421901] Add a migration task for the denormalisation into BugMessage.owner.

Description of the change

Add a migration task for the denormalisation into BugMessage.owner. This completes the work we can sensibly do until the next database downtime window.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

As discussed on IRC, for /me/ superuser_connection() is a clearer name than root_connection() ('root' is a touch overloaded and I didn't get the intent in this context).

Other than that, looks fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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:45:52 +0000
@@ -3403,42 +3403,42 @@
34033403
3404ALTER TABLE bugmessage DISABLE TRIGGER ALL;3404ALTER TABLE bugmessage DISABLE TRIGGER ALL;
34053405
3406INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (1, 2, 1, NULL, NULL, 0);3406INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (1, 2, 1, NULL, NULL, 0, 16);
3407INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (2, 1, 3, NULL, NULL, 0);3407INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (2, 1, 3, NULL, NULL, 0, 12);
3408INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (3, 1, 4, NULL, NULL, 1);3408INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (3, 1, 4, NULL, NULL, 1, 12);
3409INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (4, 2, 5, NULL, NULL, 1);3409INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (4, 2, 5, NULL, NULL, 1, 12);
3410INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (5, 2, 6, NULL, NULL, 2);3410INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (5, 2, 6, NULL, NULL, 2, 12);
3411INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (6, 4, 7, NULL, NULL, 0);3411INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (6, 4, 7, NULL, NULL, 0, 12);
3412INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (7, 5, 8, NULL, NULL, 0);3412INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (7, 5, 8, NULL, NULL, 0, 12);
3413INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (8, 6, 9, NULL, NULL, 0);3413INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (8, 6, 9, NULL, NULL, 0, 12);
3414INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (9, 3, 10, NULL, NULL, 0);3414INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (9, 3, 10, NULL, NULL, 0, 12);
3415INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (10, 7, 11, NULL, NULL, 0);3415INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (10, 7, 11, NULL, NULL, 0, 16);
3416INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (11, 8, 14, NULL, NULL, 0);3416INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (11, 8, 14, NULL, NULL, 0, 12);
3417INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (12, 9, 15, NULL, NULL, 0);3417INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (12, 9, 15, NULL, NULL, 0, 16);
3418INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (13, 10, 17, NULL, NULL, 0);3418INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (13, 10, 17, NULL, NULL, 0, 16);
3419INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (14, 10, 16, NULL, NULL, 1);3419INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (14, 10, 16, NULL, NULL, 1, 16);
3420INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (15, 11, 24, NULL, NULL, 0);3420INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (15, 11, 24, NULL, NULL, 0, 26);
3421INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (16, 11, 25, NULL, NULL, 1);3421INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (16, 11, 25, NULL, NULL, 1, 50);
3422INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (17, 11, 26, NULL, NULL, 2);3422INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (17, 11, 26, NULL, NULL, 2, 66);
3423INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (18, 11, 27, NULL, NULL, 3);3423INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (18, 11, 27, NULL, NULL, 3, 63);
3424INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (19, 11, 28, NULL, NULL, 4);3424INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (19, 11, 28, NULL, NULL, 4, 27);
3425INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (20, 11, 29, NULL, NULL, 5);3425INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (20, 11, 29, NULL, NULL, 5, 33);
3426INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (21, 11, 30, NULL, NULL, 6);3426INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (21, 11, 30, NULL, NULL, 6, 3);
3427INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (22, 12, 31, NULL, NULL, 0);3427INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (22, 12, 31, NULL, NULL, 0, 8);
3428INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (23, 12, 33, NULL, NULL, 1);3428INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (23, 12, 33, NULL, NULL, 1, 45);
3429INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (24, 12, 34, NULL, NULL, 2);3429INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (24, 12, 34, NULL, NULL, 2, 13);
3430INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (25, 12, 35, NULL, NULL, 3);3430INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (25, 12, 35, NULL, NULL, 3, 9);
3431INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (26, 12, 36, NULL, NULL, 4);3431INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (26, 12, 36, NULL, NULL, 4, 6);
3432INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (27, 13, 37, NULL, NULL, 0);3432INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (27, 13, 37, NULL, NULL, 0, 12);
3433INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (28, 13, 38, NULL, NULL, 1);3433INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (28, 13, 38, NULL, NULL, 1, 12);
3434INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (29, 14, 39, NULL, NULL, 0);3434INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (29, 14, 39, NULL, NULL, 0, 63);
3435INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (30, 15, 40, NULL, NULL, 0);3435INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (30, 15, 40, NULL, NULL, 0, 16);
3436INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (31, 15, 44, 11, '<4284D7D1.6010208@gmx.de>', 1);3436INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (31, 15, 44, 11, '<4284D7D1.6010208@gmx.de>', 1, 243614);
3437INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (32, 15, 45, 11, '<20050517185429.GB20786@spring.luon.net>', 2);3437INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (32, 15, 45, 11, '<20050517185429.GB20786@spring.luon.net>', 2, 243615);
3438INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (33, 15, 46, 11, '<428A44E9.6090802@gmx.de>', 3);3438INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (33, 15, 46, 11, '<428A44E9.6090802@gmx.de>', 3, 243614);
3439INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (34, 15, 47, 11, '<20050517202044.GA23231@spring.luon.net>', 4);3439INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (34, 15, 47, 11, '<20050517202044.GA23231@spring.luon.net>', 4, 243615);
3440INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (35, 15, 48, 11, '<20050617140011.GA15638@piware.de>', 5);3440INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (35, 15, 48, 11, '<20050617140011.GA15638@piware.de>', 5, 243616);
3441INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (36, 15, 49, 11, '<42BD2E36.9090809@gmx.de>', 6);3441INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (36, 15, 49, 11, '<42BD2E36.9090809@gmx.de>', 6, 243614);
34423442
34433443
3444ALTER TABLE bugmessage ENABLE TRIGGER ALL;3444ALTER TABLE bugmessage ENABLE TRIGGER ALL;
34453445
=== 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:45:52 +0000
@@ -3342,42 +3342,42 @@
33423342
3343ALTER TABLE bugmessage DISABLE TRIGGER ALL;3343ALTER TABLE bugmessage DISABLE TRIGGER ALL;
33443344
3345INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (1, 2, 1, NULL, NULL, 0);3345INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (1, 2, 1, NULL, NULL, 0, 16);
3346INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (2, 1, 3, NULL, NULL, 0);3346INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (2, 1, 3, NULL, NULL, 0, 12);
3347INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (3, 1, 4, NULL, NULL, 1);3347INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (3, 1, 4, NULL, NULL, 1, 12);
3348INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (4, 2, 5, NULL, NULL, 1);3348INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (4, 2, 5, NULL, NULL, 1, 12);
3349INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (5, 2, 6, NULL, NULL, 2);3349INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (5, 2, 6, NULL, NULL, 2, 12);
3350INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (6, 4, 7, NULL, NULL, 0);3350INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (6, 4, 7, NULL, NULL, 0, 12);
3351INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (7, 5, 8, NULL, NULL, 0);3351INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (7, 5, 8, NULL, NULL, 0, 12);
3352INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (8, 6, 9, NULL, NULL, 0);3352INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (8, 6, 9, NULL, NULL, 0, 12);
3353INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (9, 3, 10, NULL, NULL, 0);3353INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (9, 3, 10, NULL, NULL, 0, 12);
3354INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (10, 7, 11, NULL, NULL, 0);3354INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (10, 7, 11, NULL, NULL, 0, 16);
3355INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (11, 8, 14, NULL, NULL, 0);3355INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (11, 8, 14, NULL, NULL, 0, 12);
3356INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (12, 9, 15, NULL, NULL, 0);3356INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (12, 9, 15, NULL, NULL, 0, 16);
3357INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (13, 10, 17, NULL, NULL, 0);3357INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (13, 10, 17, NULL, NULL, 0, 16);
3358INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (14, 10, 16, NULL, NULL, 1);3358INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (14, 10, 16, NULL, NULL, 1, 16);
3359INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (15, 11, 24, NULL, NULL, 0);3359INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (15, 11, 24, NULL, NULL, 0, 26);
3360INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (16, 11, 25, NULL, NULL, 1);3360INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (16, 11, 25, NULL, NULL, 1, 50);
3361INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (17, 11, 26, NULL, NULL, 2);3361INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (17, 11, 26, NULL, NULL, 2, 66);
3362INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (18, 11, 27, NULL, NULL, 3);3362INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (18, 11, 27, NULL, NULL, 3, 63);
3363INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (19, 11, 28, NULL, NULL, 4);3363INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (19, 11, 28, NULL, NULL, 4, 27);
3364INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (20, 11, 29, NULL, NULL, 5);3364INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (20, 11, 29, NULL, NULL, 5, 33);
3365INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (21, 11, 30, NULL, NULL, 6);3365INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (21, 11, 30, NULL, NULL, 6, 3);
3366INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (22, 12, 31, NULL, NULL, 0);3366INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (22, 12, 31, NULL, NULL, 0, 8);
3367INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (23, 12, 33, NULL, NULL, 1);3367INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (23, 12, 33, NULL, NULL, 1, 45);
3368INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (24, 12, 34, NULL, NULL, 2);3368INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (24, 12, 34, NULL, NULL, 2, 13);
3369INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (25, 12, 35, NULL, NULL, 3);3369INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (25, 12, 35, NULL, NULL, 3, 9);
3370INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (26, 12, 36, NULL, NULL, 4);3370INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (26, 12, 36, NULL, NULL, 4, 6);
3371INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (27, 13, 37, NULL, NULL, 0);3371INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (27, 13, 37, NULL, NULL, 0, 12);
3372INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (28, 13, 38, NULL, NULL, 1);3372INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (28, 13, 38, NULL, NULL, 1, 12);
3373INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (29, 14, 39, NULL, NULL, 0);3373INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (29, 14, 39, NULL, NULL, 0, 63);
3374INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (30, 15, 40, NULL, NULL, 0);3374INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (30, 15, 40, NULL, NULL, 0, 16);
3375INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (31, 15, 44, 11, '<4284D7D1.6010208@gmx.de>', 1);3375INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (31, 15, 44, 11, '<4284D7D1.6010208@gmx.de>', 1, 243614);
3376INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (32, 15, 45, 11, '<20050517185429.GB20786@spring.luon.net>', 2);3376INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (32, 15, 45, 11, '<20050517185429.GB20786@spring.luon.net>', 2, 243615);
3377INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (33, 15, 46, 11, '<428A44E9.6090802@gmx.de>', 3);3377INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (33, 15, 46, 11, '<428A44E9.6090802@gmx.de>', 3, 243614);
3378INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (34, 15, 47, 11, '<20050517202044.GA23231@spring.luon.net>', 4);3378INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (34, 15, 47, 11, '<20050517202044.GA23231@spring.luon.net>', 4, 243615);
3379INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (35, 15, 48, 11, '<20050617140011.GA15638@piware.de>', 5);3379INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (35, 15, 48, 11, '<20050617140011.GA15638@piware.de>', 5, 243616);
3380INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (36, 15, 49, 11, '<42BD2E36.9090809@gmx.de>', 6);3380INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (36, 15, 49, 11, '<42BD2E36.9090809@gmx.de>', 6, 243614);
33813381
33823382
3383ALTER TABLE bugmessage ENABLE TRIGGER ALL;3383ALTER TABLE bugmessage ENABLE TRIGGER ALL;
33843384
=== 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:45:52 +0000
@@ -31,6 +31,7 @@
31from lp.app.validators.attachment import attachment_size_constraint31from lp.app.validators.attachment import attachment_size_constraint
32from lp.bugs.interfaces.bug import IBug32from lp.bugs.interfaces.bug import IBug
33from lp.bugs.interfaces.bugwatch import IBugWatch33from lp.bugs.interfaces.bugwatch import IBugWatch
34from lp.registry.interfaces.person import IPerson
34from lp.services.fields import Title35from lp.services.fields import Title
3536
3637
@@ -52,6 +53,9 @@
52 bugwatchID = Int(title=u'The bugwatch id.', readonly=True)53 bugwatchID = Int(title=u'The bugwatch id.', readonly=True)
53 remote_comment_id = TextLine(54 remote_comment_id = TextLine(
54 title=u"The id this comment has in the bugwatch's bug tracker.")55 title=u"The id this comment has in the bugwatch's bug tracker.")
56 ownerID = Attribute("The ID of the owner mirrored from the message")
57 owner = Object(schema=IPerson,
58 title=u"The Message owner mirrored from the message.", readonly=True)
5559
5660
57class IBugMessageSet(Interface):61class IBugMessageSet(Interface):
5862
=== 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:45:52 +0000
@@ -29,6 +29,7 @@
29 IBugMessage,29 IBugMessage,
30 IBugMessageSet,30 IBugMessageSet,
31 )31 )
32from lp.registry.interfaces.person import validate_public_person
3233
3334
34class BugMessage(SQLBase):35class BugMessage(SQLBase):
@@ -46,6 +47,9 @@
46 remote_comment_id = StringCol(notNull=False, default=None)47 remote_comment_id = StringCol(notNull=False, default=None)
47 # -- The index of the message is cached in the DB.48 # -- The index of the message is cached in the DB.
48 index = IntCol(notNull=True)49 index = IntCol(notNull=True)
50 # -- The owner, cached from the message table using triggers.
51 owner = ForeignKey(dbName='owner', foreignKey='Person',
52 storm_validator=validate_public_person, notNull=False)
4953
50 def __repr__(self):54 def __repr__(self):
51 return "<BugMessage at 0x%x message=%s index=%s>" % (55 return "<BugMessage at 0x%x message=%s index=%s>" % (
5256
=== 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:45:52 +0000
@@ -64,6 +64,7 @@
64from lp.bugs.interfaces.bug import IBugSet64from lp.bugs.interfaces.bug import IBugSet
65from lp.bugs.model.bug import Bug65from lp.bugs.model.bug import Bug
66from lp.bugs.model.bugattachment import BugAttachment66from lp.bugs.model.bugattachment import BugAttachment
67from lp.bugs.model.bugmessage import BugMessage
67from lp.bugs.model.bugnotification import BugNotification68from lp.bugs.model.bugnotification import BugNotification
68from lp.bugs.model.bugwatch import BugWatchActivity69from lp.bugs.model.bugwatch import BugWatchActivity
69from lp.bugs.scripts.checkwatches.scheduler import (70from lp.bugs.scripts.checkwatches.scheduler import (
@@ -692,6 +693,36 @@
692 """693 """
693694
694695
696class MirrorBugMessageOwner(TunableLoop):
697 """Mirror BugMessage.owner from Message.
698
699 Only needed until they are all set, after that triggers will maintain it.
700 """
701
702 # Test migration did 3M in 2 hours, so 5000 is ~ 10 seconds - and thats the
703 # max we want to hold a DB lock open for.
704 minimum_chunk_size = 1000
705 maximum_chunk_size = 5000
706
707 def __init__(self, log, abort_time=None):
708 super(MirrorBugMessageOwner, self).__init__(log, abort_time)
709 self.store = IMasterStore(BugMessage)
710 self.isDone = IMasterStore(BugMessage).find(
711 BugMessage, BugMessage.ownerID==None).is_empty
712
713 def __call__(self, chunk_size):
714 """See `ITunableLoop`."""
715 transaction.begin()
716 updated = self.store.execute("""update bugmessage set
717 owner=message.owner from message where
718 bugmessage.message=message.id and bugmessage.id in
719 (select id from bugmessage where owner is NULL limit %s);"""
720 % int(chunk_size)
721 ).rowcount
722 self.log.debug("Updated %s bugmessages." % updated)
723 transaction.commit()
724
725
695class BugHeatUpdater(TunableLoop):726class BugHeatUpdater(TunableLoop):
696 """A `TunableLoop` for bug heat calculations."""727 """A `TunableLoop` for bug heat calculations."""
697728
@@ -1078,6 +1109,7 @@
1078class HourlyDatabaseGarbageCollector(BaseDatabaseGarbageCollector):1109class HourlyDatabaseGarbageCollector(BaseDatabaseGarbageCollector):
1079 script_name = 'garbo-hourly'1110 script_name = 'garbo-hourly'
1080 tunable_loops = [1111 tunable_loops = [
1112 MirrorBugMessageOwner,
1081 OAuthNoncePruner,1113 OAuthNoncePruner,
1082 OpenIDConsumerNoncePruner,1114 OpenIDConsumerNoncePruner,
1083 OpenIDConsumerAssociationPruner,1115 OpenIDConsumerAssociationPruner,
10841116
=== 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:45:52 +0000
@@ -55,6 +55,7 @@
55 ZopelessDatabaseLayer,55 ZopelessDatabaseLayer,
56 )56 )
57from lp.archiveuploader.dscfile import findFile57from lp.archiveuploader.dscfile import findFile
58from lp.bugs.model.bugmessage import BugMessage
58from lp.bugs.model.bugnotification import (59from lp.bugs.model.bugnotification import (
59 BugNotification,60 BugNotification,
60 BugNotificationRecipient,61 BugNotificationRecipient,
@@ -932,3 +933,23 @@
932 self.assertFalse(spr.changelog == None)933 self.assertFalse(spr.changelog == None)
933 self.assertTrue(spr.changelog.restricted)934 self.assertTrue(spr.changelog.restricted)
934 self.assertEqual(changelog, spr.changelog.read())935 self.assertEqual(changelog, spr.changelog.read())
936
937 def test_mirror_bugmessages(self):
938 # Nuke the owner in sampledata.
939 con = DatabaseLayer._db_fixture.superuser_connection()
940 try:
941 cur = con.cursor()
942 cur.execute("ALTER TABLE bugmessage "
943 "DISABLE TRIGGER bugmessage__owner__mirror")
944 cur.execute("UPDATE bugmessage set owner=NULL")
945 cur.execute("ALTER TABLE bugmessage "
946 "ENABLE TRIGGER bugmessage__owner__mirror")
947 con.commit()
948 finally:
949 con.close()
950 store = IMasterStore(BugMessage)
951 unmigrated = store.find(BugMessage, BugMessage.ownerID==None).count
952 self.assertNotEqual(0, unmigrated())
953 self.runHourly()
954 self.assertEqual(0, unmigrated())
955
935956
=== 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:45:52 +0000
@@ -220,9 +220,14 @@
220 connection_parameters.append('port=%s' % self.host)220 connection_parameters.append('port=%s' % self.host)
221 return ' '.join(connection_parameters)221 return ' '.join(connection_parameters)
222222
223 def superuser_connection(self, dbname=None):
224 if dbname is None:
225 dbname = self.dbname
226 return psycopg2.connect(self._connectionString(dbname))
227
223 def generateResetSequencesSQL(self):228 def generateResetSequencesSQL(self):
224 """Return a SQL statement that resets all sequences."""229 """Return a SQL statement that resets all sequences."""
225 con = psycopg2.connect(self._connectionString(self.dbname))230 con = self.superuser_connection()
226 cur = con.cursor()231 cur = con.cursor()
227 try:232 try:
228 return generateResetSequencesSQL(cur)233 return generateResetSequencesSQL(cur)
@@ -243,7 +248,7 @@
243 # anyway (because they might have been incremented even if248 # anyway (because they might have been incremented even if
244 # nothing was committed), making sure not to disturb the249 # nothing was committed), making sure not to disturb the
245 # 'committed' flag, and we're done.250 # 'committed' flag, and we're done.
246 con = psycopg2.connect(self._connectionString(self.dbname))251 con = self.superuser_connection()
247 cur = con.cursor()252 cur = con.cursor()
248 if self.reset_sequences_sql is None:253 if self.reset_sequences_sql is None:
249 resetSequences(cur)254 resetSequences(cur)
@@ -261,7 +266,7 @@
261 # template database that are slow in dropping off.266 # template database that are slow in dropping off.
262 attempts = 60267 attempts = 60
263 for counter in range(0, attempts):268 for counter in range(0, attempts):
264 con = psycopg2.connect(self._connectionString(self.template))269 con = self.superuser_connection(self.template)
265 try:270 try:
266 con.set_isolation_level(0)271 con.set_isolation_level(0)
267 cur = con.cursor()272 cur = con.cursor()
@@ -321,7 +326,7 @@
321 attempts = 100326 attempts = 100
322 for i in range(0, attempts):327 for i in range(0, attempts):
323 try:328 try:
324 con = psycopg2.connect(self._connectionString(self.template))329 con = self.superuser_connection(self.template)
325 except psycopg2.OperationalError, x:330 except psycopg2.OperationalError, x:
326 if 'does not exist' in x:331 if 'does not exist' in x:
327 return332 return

Subscribers

People subscribed via source and target branches

to status/vote changes: