[IMP] forwardport: avoid locking cron when a _validate blows up

If a _validate call blows up, the entire Commit._notify cron gets
stuck, which is an issue because not only does it stop creating
forward ports, it also stops "progressing" stagings.
This commit is contained in:
Xavier Morel 2019-10-01 07:54:24 +02:00
parent 7659293a2b
commit eb9eeb670a

View File

@ -1263,6 +1263,8 @@ class Commit(models.Model):
PRs = self.env['runbot_merge.pull_requests'] PRs = self.env['runbot_merge.pull_requests']
# chances are low that we'll have more than one commit # chances are low that we'll have more than one commit
for c in self.search([('to_check', '=', True)]): for c in self.search([('to_check', '=', True)]):
try:
with self.env.cr:
c.to_check = False c.to_check = False
st = json.loads(c.statuses) st = json.loads(c.statuses)
pr = PRs.search([('head', '=', c.sha)]) pr = PRs.search([('head', '=', c.sha)])
@ -1273,8 +1275,8 @@ class Commit(models.Model):
stagings = Stagings.search([('heads', 'ilike', c.sha)]) stagings = Stagings.search([('heads', 'ilike', c.sha)])
if stagings: if stagings:
stagings._validate() stagings._validate()
except Exception:
self.env.cr.commit() _logger.exception("Failed to apply commit %s (%s)", c, c.sha)
_sql_constraints = [ _sql_constraints = [
('unique_sha', 'unique (sha)', 'no duplicated commit'), ('unique_sha', 'unique (sha)', 'no duplicated commit'),