Opened 5 weeks ago

Closed 4 weeks ago

#35921 closed Cleanup/optimization (fixed)

migration_test_data_persistence fails when running with parallelism > 1 and Postgres

Reported by: Raphael Gaschignard Owned by: Jacob Walls
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Raphael Gaschignard, Jacob Walls Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by 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. The issue triggers for me in Postgres but not with SQLite

This issue was introduced with the fix for #35660 (in commit 060a22ee2dde7aa29a5a29120087c4864887325)

Change History (8)

comment:1 by Raphael Gaschignard, 5 weeks ago

Description: modified (diff)

comment:2 by Raphael Gaschignard, 5 weeks ago

Description: modified (diff)

comment:3 by Raphael Gaschignard, 5 weeks ago

Description: modified (diff)

comment:4 by Raphael Gaschignard, 5 weeks ago

Description: modified (diff)
Summary: migration_test_data_persistence fails when running with parallelism > 1migration_test_data_persistence fails when running with parallelism > 1 and Postgres

comment:5 by Simon Charette, 5 weeks ago

Cc: Jacob Walls added

CC'ing Jacob since he worked on #35660.

comment:6 by Jacob Walls, 5 weeks ago

Has patch: set
Owner: set to Jacob Walls
Status: newassigned
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Nice catch, looks like I just need to add allow_cascade=True in the sqlflush call in the test setup. PR

comment:7 by Sarah Boyce, 4 weeks ago

Triage Stage: AcceptedReady for checkin

comment:8 by Sarah Boyce <42296566+sarahboyce@…>, 4 weeks ago

Resolution: fixed
Status: assignedclosed

In d4b2e06:

Fixed #35921 -- Fixed failure when running tests in parallel on postgres.

Follow-up to a060a22ee2dde7aa29a5a29120087c4864887325.

Note: See TracTickets for help on using tickets.
Back to Top