﻿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
36677	Parallel test runner runs system checks with database aliases before those aliases are set up	Jacob Walls	Jacob Walls	"#36083 made the parallel test runner run system checks in workers. Well and good, but the call is done before database aliases are set up.

This should explain the recent failures with the geodjango label on Github Actions, also reproducible locally, with errors like:

{{{
django.db.utils.OperationalError: connection failed: connection to server on socket ""/var/run/postgresql/.s.PGSQL.5432"" failed: FATAL:  database ""django-postgis-other"" does not exist
}}}

I'm showing this is fixed with:
{{{#!diff
diff --git a/django/test/runner.py b/django/test/runner.py
index 25089a6db1..73665a63d2 100644
--- a/django/test/runner.py
+++ b/django/test/runner.py
@@ -463,9 +463,6 @@ def _init_worker(
             process_setup(*process_setup_args)
         django.setup()
         setup_test_environment(debug=debug_mode)
-        call_command(
-            ""check"", stdout=io.StringIO(), stderr=io.StringIO(), databases=used_aliases
-        )
 
     db_aliases = used_aliases if used_aliases is not None else connections
     for alias in db_aliases:
@@ -477,6 +474,10 @@ def _init_worker(
                 connection._test_serialized_contents = value
         connection.creation.setup_worker_connection(_worker_id)
 
+    if is_spawn_or_forkserver:
+        call_command(
+            ""check"", stdout=io.StringIO(), stderr=io.StringIO(), databases=used_aliases
+        )
 
 def _run_subsuite(args):
     """"""
}}}

Regression in 606fc352799e372928fa2c978ab99f0fb6d6017c.

Interestingly, this specific failure did not manifest until e8190b370e508648b0f0ee9b86876f97d3997e14."	Bug	closed	Testing framework	6.0	Release blocker	fixed		Adam Zapletal	Ready for checkin	1	0	0	0	0	0
