Closed Bug 1225793 Opened 9 years ago Closed 9 years ago

Autoland MozreviewUpdate table should be normalized

Categories

(MozReview Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mdoglio, Assigned: dminor)

References

Details

Attachments

(1 file)

MozreviewUpdate contains the outgoing notification to mozreview and their associated request ids.
There are only 3 columns on that table:
- request_id
- pingback_url
- data text

Since we can have more than one notification per autoland request we should split this table in two: one for the autoland request (containing request_id and pingback_url) and one for the notification data.
Oh wait, does MozreviewUpdate.request_id refer to Transplant.id? If that's the case we should:
- rename request_id to transplant_id
- define request_id as a foreign key
- move pingback_url to Transplant
Blocks: 1225810
autoland: normalize mozreviewupdate table (bug 1225793) r=mdoglio
Attachment #8689517 - Flags: review?(mdoglio)
Assignee: nobody → dminor
Status: NEW → ASSIGNED
Comment on attachment 8689517 [details]
MozReview Request: autoland: normalize mozreviewupdate table (bug 1225793) r=mdoglio

https://reviewboard.mozilla.org/r/25653/#review23057

::: autoland/autoland/autoland.py:169
(Diff revision 1)
> -            insert into MozreviewUpdate(request_id,pingback_url,data)
> +            insert into MozreviewUpdate(transplant_id,data)

This is very scary. I would get rid of the github pull request table first.

::: autoland/autoland/autoland.py:362
(Diff revision 1)
> -        select request_id,pingback_url,data
> +        select transplant_id,request,data

Once you add an autoincrement id as primary key on MozreviewUpdate, you need to retrieve that instead of transplant id.

::: autoland/autoland/autoland.py:363
(Diff revision 1)
> -        from MozreviewUpdate
> +        from MozreviewUpdate, Transplant

What you really want to do here is probably either a left join or an inner join between Transplant and MozreviewUpdate. I believe the query plan for a cartesian product is slightly worse, even though the result of the query would be the same.

::: autoland/autoland/autoland.py:386
(Diff revision 1)
> -                updated.append([request_id])
> +                updated.append([transplant_id])

`updated` should refer to the rows of MozreviewUpdate using the primary key instead of transplant_id.

::: autoland/autoland/autoland.py:397
(Diff revision 1)
> -            where request_id=%s
> +            where transplant_id=%s

Here you should delete by primary key and not by transplant_id. There could be more than one event to notify to mozreview for the same transplant request and we can't miss any of them!

::: autoland/sql/schema.sql:34
(Diff revision 1)
>  create table MozreviewUpdate (\

You also need an autoincrement primary key on this table to identify its rows.
Attachment #8689517 - Flags: review?(mdoglio)
https://reviewboard.mozilla.org/r/25653/#review23057

> This is very scary. I would get rid of the github pull request table first.

I think it would make sense to remove the github pullrequest code until we're going to use it but every time I bring up the subject I'm told no :)
Instead I'll leave this code broken.
https://reviewboard.mozilla.org/r/25653/#review23057

> What you really want to do here is probably either a left join or an inner join between Transplant and MozreviewUpdate. I believe the query plan for a cartesian product is slightly worse, even though the result of the query would be the same.

My reading of the postgres docs is that an inner join is implicit with the syntax I used, but I have no problems with making it explicit.
Comment on attachment 8689517 [details]
MozReview Request: autoland: normalize mozreviewupdate table (bug 1225793) r=mdoglio

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/25653/diff/1-2/
Attachment #8689517 - Flags: review?(mdoglio)
Comment on attachment 8689517 [details]
MozReview Request: autoland: normalize mozreviewupdate table (bug 1225793) r=mdoglio

https://reviewboard.mozilla.org/r/25653/#review23203
Attachment #8689517 - Flags: review?(mdoglio) → review+
https://hg.mozilla.org/hgcustom/version-control-tools/rev/1de17d1fb561
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Product: Developer Services → MozReview
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: