mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[FIX] runbot_merge: race condition between closes #x and merging/FF
Turns out skipping locks is not very useful when there are no locks being held because we only touch the PRs *after* the merge has been applied. So finally do that, lock all of a staging's PRs before we try to fast-forward the relevant repositories, so a close command coming back from github (from having seen the closes #xxx annotation) doesn't screw us over.
This commit is contained in:
parent
0cd587fce7
commit
c34e8ca083
@ -174,6 +174,7 @@ def handle_pr(env, event):
|
|||||||
FOR UPDATE SKIP LOCKED;
|
FOR UPDATE SKIP LOCKED;
|
||||||
''', [pr_obj.id])
|
''', [pr_obj.id])
|
||||||
res = env.cr.fetchone()
|
res = env.cr.fetchone()
|
||||||
|
# FIXME: store some sort of "try to close it later" if the merge fails?
|
||||||
if not res:
|
if not res:
|
||||||
return 'Ignored: could not lock rows (probably being merged)'
|
return 'Ignored: could not lock rows (probably being merged)'
|
||||||
|
|
||||||
|
@ -1231,6 +1231,11 @@ class Stagings(models.Model):
|
|||||||
gh = {repo.name: repo.github() for repo in project.repo_ids}
|
gh = {repo.name: repo.github() for repo in project.repo_ids}
|
||||||
repo_name = None
|
repo_name = None
|
||||||
staging_heads = json.loads(self.heads)
|
staging_heads = json.loads(self.heads)
|
||||||
|
self.env.cr.execute('''
|
||||||
|
SELECT 1 FROM runbot_merge_pull_requests
|
||||||
|
WHERE id in %s
|
||||||
|
FOR UPDATE
|
||||||
|
''', [tuple(self.mapped('batch_ids.prs.id'))])
|
||||||
try:
|
try:
|
||||||
repo_name = self._safety_dance(gh, staging_heads)
|
repo_name = self._safety_dance(gh, staging_heads)
|
||||||
except exceptions.FastForwardError as e:
|
except exceptions.FastForwardError as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user