tethysplatform / tethys

The Tethys Platform main Django website project repository.
http://tethysplatform.org/
BSD 2-Clause "Simplified" License
93 stars 51 forks source link

database connection isn't set to UTC #702

Closed sdc50 closed 3 years ago

sdc50 commented 3 years ago

I just built a new tethys environment with the latest dev release and got this error:

``` Environment: Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 2.2.14 Python Version: 3.7.10 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_gravatar', 'bootstrap3', 'termsandconditions', 'tethys_config', 'tethys_apps', 'tethys_gizmos', 'tethys_services', 'tethys_compute', 'tethys_quotas', 'social_django', 'guardian', 'session_security', 'captcha', 'snowpenguin.django.recaptcha2', 'rest_framework', 'rest_framework.authtoken', 'analytical', 'channels', 'mfa', 'axes', 'uit_plus_job') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'tethys_portal.middleware.TethysMfaRequiredMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'tethys_portal.middleware.TethysSocialAuthExceptionMiddleware', 'tethys_portal.middleware.TethysAppAccessMiddleware', 'session_security.middleware.SessionSecurityMiddleware', 'axes.middleware.AxesMiddleware') Traceback: File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request) File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request) File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/tethys_portal/views/home.py" in home 23. custom_template = Setting.objects.get(name='Home Page Template').content File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/db/models/manager.py" in manager_method 82. return getattr(self.get_queryset(), name)(*args, **kwargs) File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/db/models/query.py" in get 402. num = len(clone) File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/db/models/query.py" in __len__ 256. self._fetch_all() File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/db/models/query.py" in _fetch_all 1242. self._result_cache = list(self._iterable_class(self)) File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/db/models/query.py" in __iter__ 55. results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size) File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/db/models/sql/compiler.py" in execute_sql 1173. return list(result) File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/db/models/sql/compiler.py" in cursor_iter 1552. for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel): File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/db/models/sql/compiler.py" in 1552. for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel): File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/db/utils.py" in inner 96. return func(*args, **kwargs) File "/opt/miniconda3/envs/tethys/lib/python3.7/site-packages/django/db/backends/postgresql/utils.py" in utc_tzinfo_factory 6. raise AssertionError("database connection isn't set to UTC") Exception Type: AssertionError at / Exception Value: database connection isn't set to UTC ```

It seems like it's related to this https://github.com/psycopg/psycopg2/issues/1293 and this https://github.com/django/django/pull/14530

It seems like the solution is that we need to pin psycopg2==2.8.6

msouff commented 3 years ago

@sdc50 see #698

In short psycopg2 broke this with their 2.9.* release. You can downgrade psycopg2 to 2.8.6 to fix this problem and I think Nathan already pinged this in production.

swainn commented 3 years ago

Huh. This should be pinned in dev: #699

swainn commented 3 years ago

Also, this issue was first reported on #698

swainn commented 3 years ago

@sdc50 what version of Tethys?

swainn commented 3 years ago

The latest package for 3.4.0 is this one: tethys-platform-3.4.0-dev3_gb41ca3b.tar.bz2 It may be that issue where Conda isn't able to resolve the latest version correctly.

swainn commented 3 years ago

I removed all of the old dev packages so that you won't get an old package. Conda seems to have a hard time resolving our dev tagged releases.