File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -830,7 +830,12 @@ def cfbot_ingest(message):
830830 # not it doesn't contain the newest patches that the CFBot knows about.
831831 return
832832
833- old_branch = CfbotBranch .objects .select_for_update ().filter (patch_id = patch_id ).first ()
833+ # We don't simply fetch this from the patch.cfbot_branch, because we want
834+ # to get it as select_for_update. That way we can use this row as a lock to
835+ # ensure only one cfbot HTTP request can change a patch its Branch and
836+ # Tasks at the same time. (see also transaction.atomic at the top of this
837+ # function)
838+ old_branch = CfbotBranch .objects .select_for_update ().get (pk = patch_id )
834839 if old_branch and old_branch .branch_id != branch_id and old_branch .created .replace (tzinfo = timezone .utc ) > created :
835840 # This is a message for an old branch, ignore it.
836841 return
You can’t perform that action at this time.
0 commit comments