#Unable to find the cause of deadlock

1 messages · Page 1 of 1 (latest)

drifting mango
#

Please ping me if someone reply

umbral needle
#

If you add logging, where does it hang?

drifting mango
umbral needle
#

I meant add some logging to the methods so you can try to see it, either dev or prod.

tepid python
#

Any chance you have a cyclic parent relationship? A -> B -> C -> A ?

#

Also, were there any visible errors? or is it an assumption that there's a deadlock?

drifting mango
#

I used chatgpt and it did said that there is cyclic relationship. But I'm not sure why it may be happening, since there is no lock or transaction.atomic block. so why db is locking it up ?

drifting mango
tepid python
#

A couple of hunches, I'm sorry that's as much as I can give you:

  • I remember there was a way to make all requests atomic in the settings.
  • I also believe you can still get a deadlock because the database does try to lock the records during update.
  • You should probably select_for_update to be safe
  • I'd also check if whatever is calling that get_parent_json in the first place isn't getting triggered multiple time in a row (may need to be deduped somehow)
#

Oh that looks like a pretty big project... I'm not sure how much control you have over this XD

drifting mango
#

oh so does this wrap the complete request in a trasaction ?

tepid python
#

I believe so my friend.

drifting mango
#

Ahhh ohkay

#

Thanks for help. I think this will solve it 🫠

tepid python
#

But getting that deadlock is a good thing... it highlighted your problem.