Add a lockmode for the update_notifications_status_by_id to prevent the timeout task from updating the same notification more than once.

This happens because more than one beat process was creating the timeout task, resulting in multiple workers running the same queries at the same time.
This commit is contained in:
Rebecca Law
2016-07-08 14:48:07 +01:00
parent d28775800c
commit 1bfd25107b
2 changed files with 7 additions and 5 deletions

View File

@@ -246,7 +246,7 @@ def _update_notification_status(notification, status, notification_statistics_st
@transactional
def update_notification_status_by_id(notification_id, status, notification_statistics_status=None):
notification = Notification.query.filter(
notification = Notification.query.with_lockmode("update").filter(
Notification.id == notification_id,
or_(Notification.status == 'created',
Notification.status == 'sending',