I have a method that updates a row in the table.
To avoid race condition, I locked the row using `select_for_update` inside
an `atomic` block and doing the update.
This method is called from a celery task.

This works well on my local machine. But when this gets called on my
production server (two tasks being picked up by two workers at the same
time and therefore trying to access the same row at once), I get:
`TransactionManagementError('select_for_update cannot be used outside of a
transaction.',)`

I checked that to use `select_for_update`, autocommit should be False.
Inside the atomic block `get_autocommit` returns False.

Now on production this must be returning `TRUE`.


What could be the reason?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACyRkBU8cpRgm8omT5PnkdW0-uxPF9U87TqMzm16kWmdfqkNrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to