Remove FOR UPDATE in Queue cancel and complete

We have no need for them anymore and it should reduce lock contention a bit

Fixes #776
This commit is contained in:
Joseph Schorr 2017-01-12 13:22:42 -05:00
parent 939c122f70
commit 7f63cbd14f

View file

@ -276,29 +276,11 @@ class WorkQueue(object):
""" Attempts to cancel the queue item with the given ID from the queue. Returns true on success """ Attempts to cancel the queue item with the given ID from the queue. Returns true on success
and false if the queue item could not be canceled. and false if the queue item could not be canceled.
""" """
count_removed = QueueItem.delete().where(QueueItem.id == item_id).execute()
with self._transaction_factory(db): return count_removed > 0
# Load the build queue item for update.
try:
queue_item = db_for_update(QueueItem.select()
.where(QueueItem.id == item_id)).get()
except QueueItem.DoesNotExist:
return False
# Delete the queue item.
queue_item.delete_instance(recursive=True)
return True
def complete(self, completed_item): def complete(self, completed_item):
with self._transaction_factory(db): self._currently_processing = not self.cancel(completed_item.id)
try:
completed_item_obj = self._item_by_id_for_update(completed_item.id)
except QueueItem.DoesNotExist:
self._currently_processing = False
return
completed_item_obj.delete_instance(recursive=True)
self._currently_processing = False
def incomplete(self, incomplete_item, retry_after=300, restore_retry=False): def incomplete(self, incomplete_item, retry_after=300, restore_retry=False):
with self._transaction_factory(db): with self._transaction_factory(db):