Can this result go into django + postgres?

I have two concurrent processes that start separate transactions that end up in the same code path:

@transaction.atomic 
def myFunc():
    object = x.objects.get(filter=sample_filter) // Assume this gets a single row back
    object.sample_property = "Hello World"
    object.save()

      

One of the processes keeps reporting a deadlock awaiting ShareLock on object.save (). I guess the other is not reporting because it was the one that was not killed. If these processes were knocking the same row out of X, could it result in a deadlock? I can't see how because .get () doesn't place a lock on the "object", right?

+3


source to share


1 answer


I am assuming you are using PostgreSQL and by default this is READ-COMITTED level. So yes, within your atomic transaction, for example. if you call pdb

after get()

then other code without pdb

has to wait for another transaction to complete when it reaches save()

. For your case, there should be no deadlock.



0


source







All Articles