﻿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
35967	TransactionTestCase.serialized_rollback reads from real database rather than test when using read replica for a model instance created in a migration with a ManyToManyField	Jake Howard	Simon Charette	"(Yes, this is a rather specific bug...)

When:

1. Using a database router to create a read-replica database, configured as a `MIRROR` in tests, and
2. Using `TransactionTestCase.serialized_rollback`, and
3. Having a model instance created in a migration which has a `ManyToMany` field

The serializer for `serialized_rollback` tries to read from the non-test database. If that database doesn't exist yet (for example, in CI), this throws an error:

{{{
django.db.utils.OperationalError: no such table: auth_user
}}}

If migrations are run (`manage.py migrate`), thus creating the tables for the non-test database, tests pass correctly. Prooving it's reading from the wrong connection.

I've created a [https://github.com/RealOrangeOne/django-db-serialize-repro minimal reproduction] of this issue, and confirmed it happens on SQLite, PostgreSQL and Django 4.2, 5.0, 5.1 and `main`"	Bug	closed	Testing framework	dev	Normal	fixed		Ryan Cheley Jacob Walls Simon Charette	Ready for checkin	1	0	0	0	0	0
