Merge pull request #239 from taigaio/bug/2083/user-story-history-repeats-files-and-has-no-order
Locking the element on take_snapshot to avoid racing condition issuesremotes/origin/enhancement/email-actions
commit
2d69b244b6
|
@ -30,6 +30,7 @@ django-ipware==0.1.0
|
|||
premailer==2.8.1
|
||||
django-transactional-cleanup==0.1.13
|
||||
lxml==3.4.1
|
||||
git+https://github.com/Xof/django-pglocks.git@dbb8d7375066859f897604132bd437832d2014ea
|
||||
|
||||
# Comment it if you are using python >= 3.4
|
||||
enum34==1.0
|
||||
|
|
|
@ -37,6 +37,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||
from django.core.paginator import Paginator, InvalidPage
|
||||
from django.apps import apps
|
||||
from django.db import transaction as tx
|
||||
from django_pglocks import advisory_lock
|
||||
|
||||
from taiga.mdrender.service import render as mdrender
|
||||
from taiga.base.utils.db import get_typename_for_model_class
|
||||
|
@ -269,6 +270,7 @@ def get_modified_fields(obj:object, last_modifications):
|
|||
|
||||
return modified_fields
|
||||
|
||||
|
||||
@tx.atomic
|
||||
def take_snapshot(obj:object, *, comment:str="", user=None, delete:bool=False):
|
||||
"""
|
||||
|
@ -280,6 +282,7 @@ def take_snapshot(obj:object, *, comment:str="", user=None, delete:bool=False):
|
|||
"""
|
||||
|
||||
key = make_key_from_model_object(obj)
|
||||
with advisory_lock(key) as acquired_key_lock:
|
||||
typename = get_typename_for_model_class(obj.__class__)
|
||||
|
||||
new_fobj = freeze_model_instance(obj)
|
||||
|
|
Loading…
Reference in New Issue