Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#33087 closed Bug (invalid)

Postgres: SSL connection has been closed unexpectedly

Reported by: David Babalola Owned by: nobody
Component: Database layer (models, ORM) Version: 3.2
Severity: Normal Keywords: Postgres, heroku
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I recently deployed an app to Heroku using Postgres free tier as database. I am using Django 3.2 Everything was working fine until I started getting a mail with the following error:

OperationalError at /blog/create/
terminating connection due to administrator command
SSL connection has been closed unexpectedly

It happens when I try to save a Post.
I know it's an issue with the Postgres, but I don't know what it means or how to solve it.

  1. What does this error mean?
  2. What causes the error?
  3. How can I solve it?

This is the full error trace

Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 233, in _get_session
    return self._session_cache

During handling of the above exception ('SessionStore' object has no attribute '_session_cache'), another exception occurred:
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)

The above exception (terminating connection due to administrator command
SSL connection has been closed unexpectedly
) was the direct cause of the following exception:
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 20, in _wrapped_view
    if test_func(request.user):
  File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 44, in <lambda>
    lambda u: u.is_authenticated,
  File "/app/.heroku/python/lib/python3.8/site-packages/django/utils/functional.py", line 246, in inner
    self._setup()
  File "/app/.heroku/python/lib/python3.8/site-packages/django/utils/functional.py", line 382, in _setup
    self._wrapped = self._setupfunc()
  File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/auth/middleware.py", line 23, in <lambda>
    request.user = SimpleLazyObject(lambda: get_user(request))
  File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/auth/middleware.py", line 11, in get_user
    request._cached_user = auth.get_user(request)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/auth/__init__.py", line 177, in get_user
    user_id = _get_user_session_key(request)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/auth/__init__.py", line 60, in _get_user_session_key
    return get_user_model()._meta.pk.to_python(request.session[SESSION_KEY])
  File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 65, in __getitem__
    return self._session[key]
  File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 238, in _get_session
    self._session_cache = self.load()
  File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/sessions/backends/db.py", line 43, in load
    s = self._get_session_from_db()
  File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/sessions/backends/db.py", line 32, in _get_session_from_db
    return self.model.objects.get(
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/models/query.py", line 431, in get
    num = len(clone)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/models/query.py", line 262, in __len__
    self._fetch_all()
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/models/query.py", line 51, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
    cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)

Change History (2)

comment:3 by David Babalola, 3 years ago

Component: UncategorizedDatabase layer (models, ORM)

comment:4 by Mariusz Felisiak, 3 years ago

Resolution: invalid
Status: newclosed

See TicketClosingReasons/UseSupportChannels for ways to get help. If you confirm a bug in Django, please reopen with details.

Note: See TracTickets for help on using tickets.
Back to Top