Merge lp:~edwin-grubbs/launchpad/bug-615654-registry-jobqueue-schema into lp:launchpad/db-devel

Proposed by Edwin Grubbs
Status: Merged
Merged at revision: 9873
Proposed branch: lp:~edwin-grubbs/launchpad/bug-615654-registry-jobqueue-schema
Merge into: lp:launchpad/db-devel
Diff against target: 78 lines (+45/-0)
3 files modified
database/schema/comments.sql (+16/-0)
database/schema/patch-2208-99-0.sql (+27/-0)
database/schema/security.cfg (+2/-0)
To merge this branch: bzr merge lp:~edwin-grubbs/launchpad/bug-615654-registry-jobqueue-schema
Reviewer Review Type Date Requested Status
Stuart Bishop (community) db Approve
Robert Collins db Pending
Review via email: mp+35619@code.launchpad.net

Description of the change

This branch adds the PersonTransferJob and QuestionJob tables.

The PersonTransferJob table will be used immediately to reduce or eliminate timeouts when adding lots of members to a team. In the future, the table will also be used for jobs where two person objects are merged.

The QuestionJob will be used to queue notifications about changes to the question object.

Should these jobs use new database users and have their own cronjobs? It seems like it would be much simpler to have a single cronjob run all the jobs.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Quick thoughts:
 - for question emails, perhaps a single 'emailjob' would be better, containing in it any email we want to send rather than question specific emails.
 - PTJ seems sensible to me, though I thought we'd eliminated timeouts there already; could you link a recent oops for me to peruse (and its bug)? thanks.
 - I don't see that we need new db users and cron jobs for this, though we do need one cronjob per queue AIUI today.

Revision history for this message
Stuart Bishop (stub) wrote :

I'm happy with the names. These relations have so far often been named by the tables they are joining (BranchJob, ArchiveJob) as with the job_type column, they can be used for several different types of task. Although we are not consistent - ApportJob should be BlobJob for instance.

We want a unique database user per script. If you have one script processing multiple types of jobs, that is one database user.

We will need some indexes in case these tables grow:

CREATE INDEX PersonTransferJob__minor_person__idx ON PersonTransferJob(minor_person);
CREATE INDEX PersonTransferJob__major_person__idx ON PersonTransferJob(major_person);
CREATE INDEX QuestionJob__question__idx ON QuestionJob(question);

review: Approve (db)
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Thanks for the review. Is a new user created in the db just by adding an entry to security.cfg, or do I need to do something else?

Revision history for this message
Stuart Bishop (stub) wrote :

Just the entry in security.cfg - that takes care of everything at your end.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/schema/comments.sql'
2--- database/schema/comments.sql 2010-09-16 01:27:57 +0000
3+++ database/schema/comments.sql 2010-09-17 03:13:45 +0000
4@@ -1272,6 +1272,22 @@
5 COMMENT ON COLUMN PersonNotification.subject IS 'The subject of the mail to be sent.';
6 COMMENT ON COLUMN PersonNotification.date_emailed IS 'When this notification was emailed to the relevant people.';
7
8+-- PersonTransferJob
9+
10+COMMENT ON TABLE PersonTransferJob IS 'Contains references to jobs for adding team members or merging person entries.';
11+COMMENT ON COLUMN PersonTransferJob.job IS 'A reference to a row in the Job table that has all the common job details.';
12+COMMENT ON COLUMN PersonTransferJob.job_type IS 'The type of job, like add-member notification or merge persons.';
13+COMMENT ON COLUMN PersonTransferJob.json_data IS 'Data that is specific to the type of job, normally stores text to append to email notifications.';
14+COMMENT ON COLUMN PersonTransferJob.minor_person IS 'The person that is being added is a new member or being merged into another person.';
15+COMMENT ON COLUMN PersonTransferJob.major_person IS 'The team receiving a new member or the person that another person is merged into.';
16+
17+-- QuestionJob
18+
19+COMMENT ON TABLE QuestionJob IS 'Contains references to jobs regarding questions.';
20+COMMENT ON COLUMN QuestionJob.job IS 'A reference to a row in the Job table that has all the common job details.';
21+COMMENT ON COLUMN QuestionJob.job_type IS 'The type of job, such as new-answer-notification.';
22+COMMENT ON COLUMN QuestionJob.json_data IS 'Data that is specific to the type of job, normally stores text to append to email notifications.';
23+COMMENT ON COLUMN QuestionJob.question IS 'The newly added question message.';
24
25 -- Bounty
26 COMMENT ON TABLE Bounty IS 'A set of bounties for work to be done by the open source community. These bounties will initially be offered only by Canonical, but later we will create the ability for people to offer the bounties themselves, using us as a clearing house.';
27
28=== added file 'database/schema/patch-2208-99-0.sql'
29--- database/schema/patch-2208-99-0.sql 1970-01-01 00:00:00 +0000
30+++ database/schema/patch-2208-99-0.sql 2010-09-17 03:13:45 +0000
31@@ -0,0 +1,27 @@
32+SET client_min_messages=ERROR;
33+
34+/* PersonTransferJob can handle jobs adding a member to a team
35+ * or merging to person objects.
36+ */
37+CREATE TABLE PersonTransferJob (
38+ id SERIAL PRIMARY KEY,
39+ job INTEGER NOT NULL UNIQUE REFERENCES Job(id),
40+ job_type INTEGER NOT NULL,
41+ minor_person INTEGER NOT NULL REFERENCES Person(id),
42+ major_person INTEGER NOT NULL REFERENCES Person(id),
43+ json_data text
44+);
45+
46+CREATE TABLE QuestionJob (
47+ id SERIAL PRIMARY KEY,
48+ job INTEGER NOT NULL UNIQUE REFERENCES Job(id),
49+ job_type INTEGER NOT NULL,
50+ question INTEGER NOT NULL REFERENCES Question(id),
51+ json_data text
52+);
53+
54+CREATE INDEX PersonTransferJob__minor_person__idx ON PersonTransferJob(minor_person);
55+CREATE INDEX PersonTransferJob__major_person__idx ON PersonTransferJob(major_person);
56+CREATE INDEX QuestionJob__question__idx ON QuestionJob(question);
57+
58+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 99, 0);
59
60=== modified file 'database/schema/security.cfg'
61--- database/schema/security.cfg 2010-09-10 12:59:49 +0000
62+++ database/schema/security.cfg 2010-09-17 03:13:45 +0000
63@@ -214,6 +214,7 @@
64 public.packaging = SELECT, INSERT, UPDATE, DELETE
65 public.personlanguage = SELECT, INSERT, UPDATE, DELETE
66 public.personlocation = SELECT, INSERT, UPDATE, DELETE
67+public.persontransferjob = SELECT, INSERT, UPDATE, DELETE
68 public.personnotification = SELECT, INSERT, UPDATE, DELETE
69 public.pillarname = SELECT, INSERT, DELETE
70 public.poexportrequest = SELECT, INSERT, UPDATE, DELETE
71@@ -229,6 +230,7 @@
72 public.project = SELECT
73 public.projectbounty = SELECT, INSERT, UPDATE
74 public.questionbug = SELECT, INSERT, DELETE
75+public.questionjob = SELECT, INSERT, UPDATE, DELETE
76 public.questionmessage = SELECT, INSERT
77 public.questionreopening = SELECT, INSERT, UPDATE
78 public.question = SELECT, INSERT, UPDATE

Subscribers

People subscribed via source and target branches

to status/vote changes: