[FIX] runbot: limit duplicate builds search to one

When searching for duplicate builds, a git ls-remote is used to verify
that the branch still exists. This command is time consuming (up to 2
seconds).

If the number of build is significant, it can last a very long time.

When a user push one ore more new branches without new commits, the
number of duplicate builds found may be very large (more than 92).
This loop blocks the cron wroker in charge of creating new builds.

This quick fix will limit the number of duplicate to 1 but if the
closest name is not the same, it will not be considered as a duplicate.
This commit is contained in:
Christophe Monniez 2019-02-26 15:44:58 +01:00
parent 19ffcdd4a2
commit 6e57b0954d

View File

@ -117,7 +117,7 @@ class runbot_build(models.Model):
'|', ('result', '=', False), ('result', '!=', 'skipped')
]
for duplicate in self.search(domain):
for duplicate in self.search(domain, limit=1):
duplicate_id = duplicate.id
# Consider the duplicate if its closest branches are the same than the current build closest branches.
for extra_repo in build_id.repo_id.dependency_ids: