id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 27403 Document that prefetch_related doesn't guarantee transactional consistency Aymeric Augustin Tim Bell "Let's assume a `Parent` model and a `Child` model with a FK to `Parent`. Database initially looks like this: {{{ parent1 -- child1 }}} User runs `Parent.objects.all().prefetch_related('child_set')`. Django fetches `parent1`. Another transaction commits, resulting in this structure: {{{ parent1 +- child1 `- child2 parent2 }}} Django fetches all children pointing to `parent1`, which returns `child1` and `child2`. The result of the query is: {{{ parent1 +- child1 `- child2 }}} But at no point in the history did the database look like this. This bug report is based on code inspection. I verified that `prefetch_related` doesn't start a transaction. However I didn't write code exhibiting the race condition because that's a bit complicated." Cleanup/optimization closed Documentation dev Normal fixed Shai Berger Ready for checkin 1 0 0 0 0 0