Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database connection isn't set to UTC #377

Open
craigwindell opened this issue Jul 22, 2021 · 1 comment
Open

Database connection isn't set to UTC #377

craigwindell opened this issue Jul 22, 2021 · 1 comment

Comments

@craigwindell
Copy link
Contributor

Describe the bug
Commit #f41371a

Accessing the home page of the server results in an error

uwsgi_1      | Internal Server Error: /
uwsgi_1      | Traceback (most recent call last):
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/contrib/sessions/backends/base.py", line 189, in _get_session
uwsgi_1      |     return self._session_cache
uwsgi_1      | AttributeError: 'SessionStore' object has no attribute '_session_cache'
uwsgi_1      |
uwsgi_1      | During handling of the above exception, another exception occurred:
uwsgi_1      |
uwsgi_1      | Traceback (most recent call last):
nginx_1      | 131.181.240.91 - - [22/Jul/2021:23:24:04 +0000] "GET / HTTP/1.1" 500 850 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36 Edg/91.0.864.71" "-"
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
uwsgi_1      |     response = get_response(request)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
uwsgi_1      |     response = self.process_exception_by_middleware(e, request)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
uwsgi_1      |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/ratelimit/decorators.py", line 30, in _wrapped
uwsgi_1      |     return fn(*args, **kw)
uwsgi_1      |   File "./shub/apps/base/views/main.py", line 24, in index_view
uwsgi_1      |     return render(request, "main/index.html")
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/shortcuts.py", line 36, in render
uwsgi_1      |     content = loader.render_to_string(template_name, context, request, using=using)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/loader.py", line 62, in render_to_string
uwsgi_1      |     return template.render(context, request)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
uwsgi_1      |     return self.template.render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 171, in render
uwsgi_1      |     return self._render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
uwsgi_1      |     return self.nodelist.render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 937, in render
uwsgi_1      |     bit = node.render_annotated(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
uwsgi_1      |     return self.render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render
uwsgi_1      |     return compiled_parent._render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
uwsgi_1      |     return self.nodelist.render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 937, in render
uwsgi_1      |     bit = node.render_annotated(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
uwsgi_1      |     return self.render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/loader_tags.py", line 62, in render
uwsgi_1      |     result = block.nodelist.render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 937, in render
uwsgi_1      |     bit = node.render_annotated(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
uwsgi_1      |     return self.render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/loader_tags.py", line 188, in render
uwsgi_1      |     return template.render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 173, in render
uwsgi_1      |     return self._render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
uwsgi_1      |     return self.nodelist.render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 937, in render
uwsgi_1      |     bit = node.render_annotated(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
uwsgi_1      |     return self.render(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/defaulttags.py", line 302, in render
uwsgi_1      |     match = condition.eval(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/defaulttags.py", line 876, in eval
uwsgi_1      |     return self.value.resolve(context, ignore_failures=True)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 671, in resolve
uwsgi_1      |     obj = self.var.resolve(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 796, in resolve
uwsgi_1      |     value = self._resolve_lookup(context)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
uwsgi_1      |     current = current[bit]
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 256, in inner
uwsgi_1      |     self._setup()
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 392, in _setup
uwsgi_1      |     self._wrapped = self._setupfunc()
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/middleware.py", line 24, in <lambda>
uwsgi_1      |     request.user = SimpleLazyObject(lambda: get_user(request))
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/middleware.py", line 12, in get_user
uwsgi_1      |     request._cached_user = auth.get_user(request)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/__init__.py", line 182, in get_user
uwsgi_1      |     user_id = _get_user_session_key(request)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/__init__.py", line 59, in _get_user_session_key
uwsgi_1      |     return get_user_model()._meta.pk.to_python(request.session[SESSION_KEY])
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/contrib/sessions/backends/base.py", line 54, in __getitem__
uwsgi_1      |     return self._session[key]
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/contrib/sessions/backends/base.py", line 194, in _get_session
uwsgi_1      |     self._session_cache = self.load()
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py", line 43, in load
uwsgi_1      |     s = self._get_session_from_db()
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py", line 34, in _get_session_from_db
uwsgi_1      |     expire_date__gt=timezone.now()
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
uwsgi_1      |     return getattr(self.get_queryset(), name)(*args, **kwargs)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 402, in get
uwsgi_1      |     num = len(clone)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 256, in __len__
uwsgi_1      |     self._fetch_all()
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 1242, in _fetch_all
uwsgi_1      |     self._result_cache = list(self._iterable_class(self))
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 55, in __iter__
uwsgi_1      |     results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
uwsgi_1      |     return list(result)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1554, in cursor_iter
uwsgi_1      |     for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1554, in <lambda>
uwsgi_1      |     for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 96, in inner
uwsgi_1      |     return func(*args, **kwargs)
uwsgi_1      |   File "/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/utils.py", line 6, in utc_tzinfo_factory
uwsgi_1      |     raise AssertionError("database connection isn't set to UTC")
uwsgi_1      | AssertionError: database connection isn't set to UTC

To Reproduce
Deploy Commit #f41371a and access home page

Expected behavior
The home page is displayed without error.

@vsoch
Copy link
Member

vsoch commented Jul 22, 2021

This looks like a relatively new error, and it results from the pyscogp2-binary:

https://stackoverflow.com/questions/38807296/django-1-9-2-assertionerror-database-connection-isnt-set-to-utc
So I think you can set USE_TZ to False or pin that version. Oup you have a PR - maybe you've already figured this out! 😆

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

No branches or pull requests

2 participants