﻿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
35921	migration_test_data_persistence fails when running with parallelism > 1	Raphael Gaschignard		"Steps to reproduce:

- Add the following file to `tests`, as `test_postgres.py`

{{{
import os

from test_sqlite import *  # NOQA

DATABASES = {
    ""default"": {
        ""ENGINE"": ""django.db.backends.postgresql"",
        ""USER"": ""user"",
        ""NAME"": ""django"",
        ""PASSWORD"": ""postgres"",
        ""HOST"": ""localhost"",
        ""PORT"": 5432,
        ""OPTIONS"": {
            ""server_side_binding"": os.getenv(""SERVER_SIDE_BINDING"") == ""1"",
        },
    },
    ""other"": {
        ""ENGINE"": ""django.db.backends.postgresql"",
        ""USER"": ""user"",
        ""NAME"": ""django2"",
        ""PASSWORD"": ""postgres"",
        ""HOST"": ""localhost"",
        ""PORT"": 5432,
    },
}
}}}

- In `tests`, run the following:

{{{
python runtests.py --settings=test_postgres -k migration_test_data_persistence --parallel=2
}}}

An error occurs (for me at least) of the variety:

{{{
psycopg.errors.FeatureNotSupported: cannot truncate a table referenced in a foreign key constraint
DETAIL:  Table ""model_package_advertisement_publications"" references ""model_package_publication"".
HINT:  Truncate table ""model_package_advertisement_publications"" at the same time, or use TRUNCATE ... CASCADE.
}}}

Running with `--parallel=1` does not trigger this issue. I imagine that something is happening regarding the test sharding code, given that this test calls out to a command that might not be persisting the sharding logic."	Bug	new	Testing framework	dev	Normal			Raphael Gaschignard	Unreviewed	0	0	0	0	0	0
