Skip to content

Conversation

@nessita
Copy link
Contributor

@nessita nessita commented Oct 27, 2025

This change fixes recent CI issues when using parallel > 1 as follows:

2025-10-26T03:13:02.4339481Z ====================================================================== 2025-10-26T03:13:02.4340303Z ERROR: test_ops_class (indexes.tests.SchemaIndexesPostgreSQLTests.test_ops_class) 2025-10-26T03:13:02.4341128Z ---------------------------------------------------------------------- 2025-10-26T03:13:02.4341588Z Traceback (most recent call last):
2025-10-26T03:13:02.4342502Z   File "/home/runner/work/django/django/django/db/backends/utils.py", line 103, in _execute
2025-10-26T03:13:02.4343320Z     return self.cursor.execute(sql)
2025-10-26T03:13:02.4343606Z     ^^^^^^^
2025-10-26T03:13:02.4346259Z   File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/psycopg/cursor.py", line 97, in execute
2025-10-26T03:13:02.4347143Z     raise ex.with_traceback(None)
2025-10-26T03:13:02.4347516Z     ^^^^^^^^^^^
2025-10-26T03:13:02.4348018Z psycopg.errors.DuplicateTable: relation "test_ops_class" already exists
2025-10-26T03:13:02.4348867Z
2025-10-26T03:13:02.4349194Z The above exception was the direct cause of the following exception:
2025-10-26T03:13:02.4349664Z
2025-10-26T03:13:02.4349819Z Traceback (most recent call last):
2025-10-26T03:13:02.4351013Z   File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/unittest/case.py", line 58, in testPartExecutor
2025-10-26T03:13:02.4351803Z     yield
2025-10-26T03:13:02.4352590Z   File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/unittest/case.py", line 669, in run
2025-10-26T03:13:02.4353481Z     self._callTestMethod(testMethod)
2025-10-26T03:13:02.4353965Z
2025-10-26T03:13:02.4354780Z   File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/unittest/case.py", line 615, in _callTestMethod
2025-10-26T03:13:02.4356010Z     result = method()
2025-10-26T03:13:02.4356408Z     ^^^^^^^^^^^^^^^
2025-10-26T03:13:02.4357215Z   File "/home/runner/work/django/django/tests/indexes/tests.py", line 184, in test_ops_class
2025-10-26T03:13:02.4358028Z     editor.add_index(IndexedArticle2, index)
2025-10-26T03:13:02.4358453Z     ^^^^^^^^^^^
2025-10-26T03:13:02.4359276Z   File "/home/runner/work/django/django/django/db/backends/postgresql/schema.py", line 317, in add_index
2025-10-26T03:13:02.4360155Z     self.execute(
2025-10-26T03:13:02.4361078Z   File "/home/runner/work/django/django/django/db/backends/postgresql/schema.py", line 45, in execute
2025-10-26T03:13:02.4361996Z     return super().execute(sql, params)
2025-10-26T03:13:02.4362423Z     ^^^^^^^^^^^
2025-10-26T03:13:02.4363187Z   File "/home/runner/work/django/django/django/db/backends/base/schema.py", line 205, in execute
2025-10-26T03:13:02.4364021Z     cursor.execute(sql, params)
2025-10-26T03:13:02.4364401Z     ^^^^^^^
2025-10-26T03:13:02.4365053Z   File "/home/runner/work/django/django/django/db/backends/utils.py", line 79, in execute
2025-10-26T03:13:02.4366060Z     return self._execute_with_wrappers(
2025-10-26T03:13:02.4366513Z     ^^^^^^^^^^^^^^^
2025-10-26T03:13:02.4367349Z   File "/home/runner/work/django/django/django/db/backends/utils.py", line 92, in _execute_with_wrappers
2025-10-26T03:13:02.4368262Z     return executor(sql, params, many, context)
2025-10-26T03:13:02.4368723Z     ^^^^^^^^^^^^^^^
2025-10-26T03:13:02.4369459Z   File "/home/runner/work/django/django/django/db/backends/utils.py", line 100, in _execute
2025-10-26T03:13:02.4370316Z     with self.db.wrap_database_errors:
2025-10-26T03:13:02.4370730Z     ^^^^^^^^^^^^^^^
2025-10-26T03:13:02.4371377Z   File "/home/runner/work/django/django/django/db/utils.py", line 94, in __exit__
2025-10-26T03:13:02.4372232Z     raise dj_exc_value.with_traceback(traceback) from exc_value
2025-10-26T03:13:02.4376460Z     ^^^^^^^
2025-10-26T03:13:02.4377846Z   File "/home/runner/work/django/django/django/db/backends/utils.py", line 103, in _execute
2025-10-26T03:13:02.4378971Z     return self.cursor.execute(sql)
2025-10-26T03:13:02.4379398Z     ^^^^^^^
2025-10-26T03:13:02.4380458Z   File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/psycopg/cursor.py", line 97, in execute
2025-10-26T03:13:02.4381662Z     raise ex.with_traceback(None)
2025-10-26T03:13:02.4382073Z     ^^^^^^^^^^^
2025-10-26T03:13:02.4382650Z django.db.utils.ProgrammingError: relation "test_ops_class" already exists

Trac ticket number

ticket-36596

Branch description

Since the recent upgrade of GHA to 3.14, scheduled tests for Postgres have been failing with the traceback shown above. The traceback is caused by a collision between indexes.tests.SchemaIndexesNotPostgreSQLTests.test_create_index_ignores_opclasses and indexes.tests.SchemaIndexesPostgreSQLTests.test_ops_class. The former should be skipped for Postgresql.

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.

@nessita nessita force-pushed the relation-test_ops_class-already-exists branch from 21660dc to b021b6b Compare October 27, 2025 19:10
Thank you Jacob Walls for your help understanding this issue.

This change fixes recent CI issues when using parallel > 1 as follows:

2025-10-26T03:13:02.4339481Z ======================================================================
2025-10-26T03:13:02.4340303Z ERROR: test_ops_class (indexes.tests.SchemaIndexesPostgreSQLTests.test_ops_class)
2025-10-26T03:13:02.4341128Z ----------------------------------------------------------------------
2025-10-26T03:13:02.4341588Z Traceback (most recent call last):
2025-10-26T03:13:02.4342502Z   File "/home/runner/work/django/django/django/db/backends/utils.py", line 103, in _execute
2025-10-26T03:13:02.4343320Z     return self.cursor.execute(sql)
2025-10-26T03:13:02.4343606Z     ^^^^^^^
2025-10-26T03:13:02.4346259Z   File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/psycopg/cursor.py", line 97, in execute
2025-10-26T03:13:02.4347143Z     raise ex.with_traceback(None)
2025-10-26T03:13:02.4347516Z     ^^^^^^^^^^^
2025-10-26T03:13:02.4348018Z psycopg.errors.DuplicateTable: relation "test_ops_class" already exists
2025-10-26T03:13:02.4348867Z
2025-10-26T03:13:02.4349194Z The above exception was the direct cause of the following exception:
2025-10-26T03:13:02.4349664Z
2025-10-26T03:13:02.4349819Z Traceback (most recent call last):
2025-10-26T03:13:02.4351013Z   File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/unittest/case.py", line 58, in testPartExecutor
2025-10-26T03:13:02.4351803Z     yield
2025-10-26T03:13:02.4352590Z   File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/unittest/case.py", line 669, in run
2025-10-26T03:13:02.4353481Z     self._callTestMethod(testMethod)
2025-10-26T03:13:02.4353965Z
2025-10-26T03:13:02.4354780Z   File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/unittest/case.py", line 615, in _callTestMethod
2025-10-26T03:13:02.4356010Z     result = method()
2025-10-26T03:13:02.4356408Z     ^^^^^^^^^^^^^^^
2025-10-26T03:13:02.4357215Z   File "/home/runner/work/django/django/tests/indexes/tests.py", line 184, in test_ops_class
2025-10-26T03:13:02.4358028Z     editor.add_index(IndexedArticle2, index)
2025-10-26T03:13:02.4358453Z     ^^^^^^^^^^^
2025-10-26T03:13:02.4359276Z   File "/home/runner/work/django/django/django/db/backends/postgresql/schema.py", line 317, in add_index
2025-10-26T03:13:02.4360155Z     self.execute(
2025-10-26T03:13:02.4361078Z   File "/home/runner/work/django/django/django/db/backends/postgresql/schema.py", line 45, in execute
2025-10-26T03:13:02.4361996Z     return super().execute(sql, params)
2025-10-26T03:13:02.4362423Z     ^^^^^^^^^^^
2025-10-26T03:13:02.4363187Z   File "/home/runner/work/django/django/django/db/backends/base/schema.py", line 205, in execute
2025-10-26T03:13:02.4364021Z     cursor.execute(sql, params)
2025-10-26T03:13:02.4364401Z     ^^^^^^^
2025-10-26T03:13:02.4365053Z   File "/home/runner/work/django/django/django/db/backends/utils.py", line 79, in execute
2025-10-26T03:13:02.4366060Z     return self._execute_with_wrappers(
2025-10-26T03:13:02.4366513Z     ^^^^^^^^^^^^^^^
2025-10-26T03:13:02.4367349Z   File "/home/runner/work/django/django/django/db/backends/utils.py", line 92, in _execute_with_wrappers
2025-10-26T03:13:02.4368262Z     return executor(sql, params, many, context)
2025-10-26T03:13:02.4368723Z     ^^^^^^^^^^^^^^^
2025-10-26T03:13:02.4369459Z   File "/home/runner/work/django/django/django/db/backends/utils.py", line 100, in _execute
2025-10-26T03:13:02.4370316Z     with self.db.wrap_database_errors:
2025-10-26T03:13:02.4370730Z     ^^^^^^^^^^^^^^^
2025-10-26T03:13:02.4371377Z   File "/home/runner/work/django/django/django/db/utils.py", line 94, in __exit__
2025-10-26T03:13:02.4372232Z     raise dj_exc_value.with_traceback(traceback) from exc_value
2025-10-26T03:13:02.4376460Z     ^^^^^^^
2025-10-26T03:13:02.4377846Z   File "/home/runner/work/django/django/django/db/backends/utils.py", line 103, in _execute
2025-10-26T03:13:02.4378971Z     return self.cursor.execute(sql)
2025-10-26T03:13:02.4379398Z     ^^^^^^^
2025-10-26T03:13:02.4380458Z   File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/psycopg/cursor.py", line 97, in execute
2025-10-26T03:13:02.4381662Z     raise ex.with_traceback(None)
2025-10-26T03:13:02.4382073Z     ^^^^^^^^^^^
2025-10-26T03:13:02.4382650Z django.db.utils.ProgrammingError: relation "test_ops_class" already exists
@nessita nessita force-pushed the relation-test_ops_class-already-exists branch from b021b6b to fd063e3 Compare October 27, 2025 19:32
self.assertIn("charfield_added", str(editor.deferred_sql[0].parts["name"]))


@skipIf(connection.vendor == "postgresql", "No PostgreSQL tests")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, this test was already skipped by django_test_skips. What does it change to use skipIf instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like an issue with django_test_skips and forkserver 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like an issue with django_test_skips and forkserver 🤔

It's a general issue with parallel tests execution with spawn and forkserver, see alternative PR #20012.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Mariusz. As you found out, yes this is an issue with django_test_skips and the parallel tests, reported by Jacob in the referenced ticket-36596 (and django_test_expected_failures are also affected). I'll continue the conversation in your PR.

@jacobtylerwalls
Copy link
Member

Superseded by #20012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants