#Unable to find the cause of deadlock
1 messages · Page 1 of 1 (latest)
If you add logging, where does it hang?
I have sentry logs , i couldn't reproduce it locally
I meant add some logging to the methods so you can try to see it, either dev or prod.
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?
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 ?
I've got sentry logs , it's confirmed
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
There ... => https://github.com/ohcnetwork/care/blob/develop/config/settings/base.py#L73
ATOMIC_REQUESTS = True
oh so does this wrap the complete request in a trasaction ?
But getting that deadlock is a good thing... it highlighted your problem.