launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00146
[Merge] lp:~jtv/launchpad/bug-602333 into lp:launchpad/devel
Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/bug-602333 into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers): code
Related bugs:
#602333 IntegrityError: update or delete on table "job" violates foreign key constraint "buildqueue__job__fk" on table "buildqueue"
https://bugs.launchpad.net/bugs/602333
= Bug 602333 =
Deleting branches can fail because of foreign-key constraints in the buildfarm classes. It may be best to read the bug comments before reviewing this.
A branch can have BranchJobs attached. The references look like this:
Branch <- BranchJob -> Job
Branch deletion breaks the foreign-key constraint by deleting the Job; the schema is set up to let that deletion cascade to BranchJob.
One type of BranchJob is TranslationTemplatesBuildJob. This is a job for the build farm, so it comes with a BuildQueue entry attached (which goes away when the job completes). Looking at the object-oriented side, there is no direct reference between the BuildQueue and the Job; they are linked only in that they both refer to Job.
Branch <- BranchJob -> Job <- BuildQueue
The reference from BuildQueue to Job does not cascade deletions, so the Job cannot be deleted as long as the BuildQueue exists. Nor would it be reasonable to make it cascade, since BuildQueue in the general case has no connection to any BranchJob that might be deleted in this way. It's a peculiarity of TranslationTemplatesBuildJob.
After discussion with Aaron and Jono, I fixed this in a manner that's consistent with how the tie between Branch and BranchJob is broken: delete any BuildQueue entries straight from the database before deleting the Jobs.
Test:
{{{
./bin/test -vvc -m lp.code.tests.test_branch -t TestBranchDeletion
}}}
You'll also see some drive-by lint cleanups. And I moved two tests that were clearly in the wrong test case.
Jeroen
--
https://code.launchpad.net/~jtv/launchpad/bug-602333/+merge/30195
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/bug-602333 into lp:launchpad/devel.
Follow ups