Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Fix a race condition on multiple tasks getting assigned to the same machine #3106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cuckoo/core/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ def lock_machine(self, label=None, platform=None, tags=None):
raise CuckooOperationalError("No machines match selection criteria.")

# Get the first free machine.
machine = machines.filter_by(locked=False).first()
machine = machines.filter_by(locked=False).with_for_update().first()
except SQLAlchemyError as e:
log.exception("Database error locking machine: {0}".format(e))
session.close()
Expand Down