Why should a Celery task be dispatched using transaction.on_commit()?
- A To improve throughput
- B Because the worker may otherwise query a row before the transaction has committed
- C To reduce memory usage
- D Because tasks cannot run inside transactions
Answer
Because the worker may otherwise query a row before the transaction has committed
Dispatching inside an open transaction creates a race where the worker looks up an object that is not yet visible, producing intermittent failures.





