Comment 2 for bug 602333

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

The root problem is that Branch removes BranchJobs in the database, whereas TranslationTemplatesBuildJob (which is backed by the BranchJob table) expects to be cleaned up through destroySelf calls that let it clean up the associated BuildQueue. This is a reasonable optimization since we have had performance problems when deleting branches in the past. The job records stick around indefinitely after completion, so a branch may have accumulated too many to process individually python-side. BuildQueue records are deleted after completion, which is why the problem isn't always visible.

TranslationTemplatesBuildJob is part of two class families (branch jobs and build-farm jobs) that impose conflicting requirements. BranchJob has a cascading delete on its foreign key to Job, which means that objects backed by BranchJob rows are required to support direct deletion. BuildQueue on the other hand expects to be deleted before the Job goes, through a destroySelf on the TranslationTemplatesBuildJob. It would not be reasonable to make Job deletions cascade to BuildQueue just to support this one case.

I'm attaching a branch that fixes this by having branch deletion clean up attached BuildQueue records first.