[Django] #30787: update_connections_time_zone fails with parallel tests

8 views
Skip to first unread message

Django

unread,
Sep 19, 2019, 12:55:42 PM9/19/19
to django-...@googlegroups.com
#30787: update_connections_time_zone fails with parallel tests
---------------------------------------------+------------------------
Reporter: Justin Walters | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
I have extended the DiscoverRunner to wrap
`override_settings(USE_TZ=False)` around setup_databases and run_suite, in
order to allow my tests and migrations to peacefully use timezone-naive
test data.

I just began using the `manage.py test --parallel` to run my tests in
parallel. However, even though my tests succeed, the test runner crashes
before exiting, with the below exception. My test database does not get
torn down as a result. If I remove the `override_settings(USE_TZ=False)`
the exception never occurs.

My guess is that `django.test.signals.update_connections_time_zone` does
not gracefully handle the connection being closed before the function
completes. But I think it smells to just silence this exception in this
function, and am worried that perhaps my own code somewhere is abusing the
db connection. Thoughts?

{{{
Traceback (most recent call last):
File "./manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/__init__.py", line 371, in
execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-
packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/commands/test.py", line 26, in
run_from_argv
super().run_from_argv(argv)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/commands/test.py", line 59, in handle
failures = test_runner.run_tests(test_labels)
File "/usr/local/lib/python3.6/site-packages/django/test/runner.py",
line 603, in run_tests
result = self.run_suite(suite)
File "/code/application/test_runner.py", line 30, in run_suite
return super(TestRunner, self).run_suite(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/django/test/utils.py", line
343, in __exit__
self.disable()
File "/usr/local/lib/python3.6/site-packages/django/test/utils.py", line
419, in disable
setting=key, value=new_value, enter=False)
File "/usr/local/lib/python3.6/site-
packages/django/dispatch/dispatcher.py", line 178, in send
for receiver in self._live_receivers(sender)
File "/usr/local/lib/python3.6/site-
packages/django/dispatch/dispatcher.py", line 178, in <listcomp>
for receiver in self._live_receivers(sender)
File "/usr/local/lib/python3.6/site-packages/django/test/signals.py",
line 74, in update_connections_time_zone
conn.ensure_timezone()
File "/usr/local/lib/python3.6/site-
packages/django/db/backends/postgresql/base.py", line 193, in
ensure_timezone
cursor.execute(self.ops.set_time_zone_sql(), [timezone_name])
psycopg2.OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30787>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 19, 2019, 4:59:30 PM9/19/19
to django-...@googlegroups.com
#30787: update_connections_time_zone fails with parallel tests
-----------------------------------+--------------------------------------

Reporter: Justin Walters | Owner: nobody
Type: Bug | Status: closed

Component: Testing framework | Version: 2.0
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Simon Charette):

* status: new => closed
* resolution: => duplicate


Comment:

This should be fixed by 7071f8f2729295b0da77b6c651966dc32c71f1ab (#30193)
which is part of the upcoming 3.0 release.

You can confirm it's the case by trying it out against the currently
released alpha by installing it from pypi `pip install Django==3.0a1`.

Please reopen this ticket if it's not the case.

--
Ticket URL: <https://code.djangoproject.com/ticket/30787#comment:1>

Django

unread,
Sep 25, 2019, 4:17:44 PM9/25/19
to django-...@googlegroups.com
#30787: update_connections_time_zone fails with parallel tests
-----------------------------------+--------------------------------------

Reporter: Justin Walters | Owner: nobody
Type: Bug | Status: closed

Component: Testing framework | Version: 2.0
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Justin Walters):

Thanks Simon!

--
Ticket URL: <https://code.djangoproject.com/ticket/30787#comment:2>

Reply all
Reply to author
Forward
0 new messages