fpdcc / ccfp-asset-dashboard

CCFP Asset Dashboard
0 stars 1 forks source link

can't login to staging? #239

Closed smcalilly closed 1 year ago

smcalilly commented 1 year ago

@glw discovered that the login issue causes a 500 error.

server logs:

2023-05-17T14:14:32.283894+00:00 app[web.1]: [2023-05-17 14:14:32 +0000] [16] [DEBUG] POST /accounts/login/
2023-05-17T14:14:32.369097+00:00 app[web.1]: Internal Server Error: /accounts/login/
2023-05-17T14:14:32.369099+00:00 app[web.1]: Traceback (most recent call last):
2023-05-17T14:14:32.369100+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
2023-05-17T14:14:32.369100+00:00 app[web.1]: return self.cursor.execute(sql, params)
2023-05-17T14:14:32.369102+00:00 app[web.1]: psycopg2.errors.InsufficientPrivilege: permission denied for table django_session
2023-05-17T14:14:32.369103+00:00 app[web.1]:
2023-05-17T14:14:32.369104+00:00 app[web.1]:
2023-05-17T14:14:32.369104+00:00 app[web.1]: The above exception was the direct cause of the following exception:
2023-05-17T14:14:32.369105+00:00 app[web.1]:
2023-05-17T14:14:32.369105+00:00 app[web.1]: Traceback (most recent call last):
2023-05-17T14:14:32.369105+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
2023-05-17T14:14:32.369105+00:00 app[web.1]: response = get_response(request)
2023-05-17T14:14:32.369106+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
2023-05-17T14:14:32.369106+00:00 app[web.1]: response = wrapped_callback(request, *callback_args, **callback_kwargs)
2023-05-17T14:14:32.369107+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
2023-05-17T14:14:32.369114+00:00 app[web.1]: return self.dispatch(request, *args, **kwargs)
2023-05-17T14:14:32.369114+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
2023-05-17T14:14:32.369115+00:00 app[web.1]: return bound_method(*args, **kwargs)
2023-05-17T14:14:32.369115+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/views/decorators/debug.py", line 89, in sensitive_post_parameters_wrapper
2023-05-17T14:14:32.369115+00:00 app[web.1]: return view(request, *args, **kwargs)
2023-05-17T14:14:32.369116+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
2023-05-17T14:14:32.369116+00:00 app[web.1]: return bound_method(*args, **kwargs)
2023-05-17T14:14:32.369116+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
2023-05-17T14:14:32.369117+00:00 app[web.1]: response = view_func(request, *args, **kwargs)
2023-05-17T14:14:32.369117+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
2023-05-17T14:14:32.369117+00:00 app[web.1]: return bound_method(*args, **kwargs)
2023-05-17T14:14:32.369118+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
2023-05-17T14:14:32.369118+00:00 app[web.1]: response = view_func(request, *args, **kwargs)
2023-05-17T14:14:32.369118+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/views.py", line 63, in dispatch
2023-05-17T14:14:32.369118+00:00 app[web.1]: return super().dispatch(request, *args, **kwargs)
2023-05-17T14:14:32.369119+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
2023-05-17T14:14:32.369119+00:00 app[web.1]: return handler(request, *args, **kwargs)
2023-05-17T14:14:32.369119+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/views/generic/edit.py", line 142, in post
2023-05-17T14:14:32.369119+00:00 app[web.1]: return self.form_valid(form)
2023-05-17T14:14:32.369119+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/views.py", line 92, in form_valid
2023-05-17T14:14:32.369120+00:00 app[web.1]: auth_login(self.request, form.get_user())
2023-05-17T14:14:32.369120+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/__init__.py", line 108, in login
2023-05-17T14:14:32.369121+00:00 app[web.1]: request.session.cycle_key()
2023-05-17T14:14:32.369121+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 344, in cycle_key
2023-05-17T14:14:32.369121+00:00 app[web.1]: self.create()
2023-05-17T14:14:32.369122+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/db.py", line 55, in create
2023-05-17T14:14:32.369122+00:00 app[web.1]: self.save(must_create=True)
2023-05-17T14:14:32.369122+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/db.py", line 87, in save
2023-05-17T14:14:32.369122+00:00 app[web.1]: obj.save(force_insert=must_create, force_update=not must_create, using=using)
2023-05-17T14:14:32.369122+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 753, in save
2023-05-17T14:14:32.369123+00:00 app[web.1]: self.save_base(using=using, force_insert=force_insert,
2023-05-17T14:14:32.369123+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 790, in save_base
2023-05-17T14:14:32.369123+00:00 app[web.1]: updated = self._save_table(
2023-05-17T14:14:32.369123+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 895, in _save_table
2023-05-17T14:14:32.369123+00:00 app[web.1]: results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
2023-05-17T14:14:32.369124+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 933, in _do_insert
2023-05-17T14:14:32.369124+00:00 app[web.1]: return manager._insert(
2023-05-17T14:14:32.369124+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
2023-05-17T14:14:32.369124+00:00 app[web.1]: return getattr(self.get_queryset(), name)(*args, **kwargs)
2023-05-17T14:14:32.369124+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 1254, in _insert
2023-05-17T14:14:32.369125+00:00 app[web.1]: return query.get_compiler(using=using).execute_sql(returning_fields)
2023-05-17T14:14:32.369125+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1397, in execute_sql
2023-05-17T14:14:32.369125+00:00 app[web.1]: cursor.execute(sql, params)
2023-05-17T14:14:32.369130+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
2023-05-17T14:14:32.369130+00:00 app[web.1]: return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
2023-05-17T14:14:32.369130+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
2023-05-17T14:14:32.369130+00:00 app[web.1]: return executor(sql, params, many, context)
2023-05-17T14:14:32.369131+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
2023-05-17T14:14:32.369131+00:00 app[web.1]: return self.cursor.execute(sql, params)
2023-05-17T14:14:32.369131+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
2023-05-17T14:14:32.369131+00:00 app[web.1]: raise dj_exc_value.with_traceback(traceback) from exc_value
2023-05-17T14:14:32.369131+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
2023-05-17T14:14:32.369132+00:00 app[web.1]: return self.cursor.execute(sql, params)
2023-05-17T14:14:32.369132+00:00 app[web.1]: django.db.utils.ProgrammingError: permission denied for table django_session
2023-05-17T14:14:32.369132+00:00 app[web.1]:
2023-05-17T14:14:32.369518+00:00 heroku[router]: at=info method=POST path="/accounts/login/?next=/" host=ccfp-asset-dashboard-staging.herokuapp.com request_id=be62184a-110d-4880-b732-3f432bb606bd fwd="108.248.50.187" dyno=web.1 connect=0ms service=86ms status=500 bytes=3025 protocol=https
2023-05-17T14:16:01.823639+00:00 app[web.1]: [2023-05-17 14:16:01 +0000] [16] [DEBUG] Closing connection.
2023-05-17T14:18:06.106831+00:00 app[web.1]: [2023-05-17 14:18:06 +0000] [17] [DEBUG] Closing connection.
2023-05-17T14:20:09.963076+00:00 app[web.1]: [2023-05-17 14:20:09 +0000] [18] [DEBUG] Closing connection.
2023-05-17T14:22:13.897742+00:00 app[web.1]: [2023-05-17 14:22:13 +0000] [16] [DEBUG] Closing connection.
2023-05-17T14:24:17.765887+00:00 app[web.1]: [2023-05-17 14:24:17 +0000] [17] [DEBUG] Closing connection.
2023-05-17T14:26:21.979134+00:00 app[web.1]: [2023-05-17 14:26:21 +0000] [18] [DEBUG] Closing connection.
2023-05-17T14:26:42.876410+00:00 app[api]: Starting process with command `python manage.py changepassword smcalilly` by user sam.mcalilly@datamade.us
2023-05-17T14:27:03.577495+00:00 heroku[run.6830]: State changed from starting to up
2023-05-17T14:27:03.501490+00:00 heroku[run.6830]: Awaiting client
2023-05-17T14:27:03.517007+00:00 heroku[run.6830]: Starting process with command `python manage.py changepassword smcalilly`
2023-05-17T14:27:18.686789+00:00 heroku[run.6830]: Process exited with status 0
2023-05-17T14:27:18.739933+00:00 heroku[run.6830]: State changed from up to complete
2023-05-17T14:27:30.693185+00:00 heroku[router]: at=info method=GET path="/accounts/login/" host=ccfp-asset-dashboard-staging.herokuapp.com request_id=a7021ac2-b7d4-4526-99de-23d90ce3c792 fwd="108.248.50.187" dyno=web.1 connect=0ms service=4ms status=200 bytes=4028 protocol=https
2023-05-17T14:27:30.689264+00:00 app[web.1]: [2023-05-17 14:27:30 +0000] [16] [DEBUG] GET /accounts/login/
2023-05-17T14:27:30.877239+00:00 app[web.1]: [2023-05-17 14:27:30 +0000] [17] [DEBUG] GET /static/images/favicon-32x32.7e8b14aad223.png
2023-05-17T14:27:30.878502+00:00 heroku[router]: at=info method=GET path="/static/images/favicon-32x32.7e8b14aad223.png" host=ccfp-asset-dashboard-staging.herokuapp.com request_id=5a4a164a-9c22-490f-b9d9-cad146cf5451 fwd="108.248.50.187" dyno=web.1 connect=0ms service=1ms status=200 bytes=1512 protocol=https
2023-05-17T14:27:36.732741+00:00 app[web.1]: [2023-05-17 14:27:36 +0000] [18] [DEBUG] POST /accounts/login/
2023-05-17T14:27:36.845915+00:00 app[web.1]: Internal Server Error: /accounts/login/
2023-05-17T14:27:36.845917+00:00 app[web.1]: Traceback (most recent call last):
2023-05-17T14:27:36.845920+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
2023-05-17T14:27:36.845921+00:00 app[web.1]: return self.cursor.execute(sql, params)
2023-05-17T14:27:36.845921+00:00 app[web.1]: psycopg2.errors.InsufficientPrivilege: permission denied for table django_session
2023-05-17T14:27:36.845922+00:00 app[web.1]:
2023-05-17T14:27:36.845922+00:00 app[web.1]:
2023-05-17T14:27:36.845931+00:00 app[web.1]: The above exception was the direct cause of the following exception:
2023-05-17T14:27:36.845931+00:00 app[web.1]:
2023-05-17T14:27:36.845931+00:00 app[web.1]: Traceback (most recent call last):
2023-05-17T14:27:36.845932+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
2023-05-17T14:27:36.845932+00:00 app[web.1]: response = get_response(request)
2023-05-17T14:27:36.845932+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
2023-05-17T14:27:36.845932+00:00 app[web.1]: response = wrapped_callback(request, *callback_args, **callback_kwargs)
2023-05-17T14:27:36.845933+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
2023-05-17T14:27:36.845933+00:00 app[web.1]: return self.dispatch(request, *args, **kwargs)
2023-05-17T14:27:36.845933+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
2023-05-17T14:27:36.845933+00:00 app[web.1]: return bound_method(*args, **kwargs)
2023-05-17T14:27:36.845934+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/views/decorators/debug.py", line 89, in sensitive_post_parameters_wrapper
2023-05-17T14:27:36.845934+00:00 app[web.1]: return view(request, *args, **kwargs)
2023-05-17T14:27:36.845935+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
2023-05-17T14:27:36.845935+00:00 app[web.1]: return bound_method(*args, **kwargs)
2023-05-17T14:27:36.845935+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
2023-05-17T14:27:36.845935+00:00 app[web.1]: response = view_func(request, *args, **kwargs)
2023-05-17T14:27:36.845935+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
2023-05-17T14:27:36.845936+00:00 app[web.1]: return bound_method(*args, **kwargs)
2023-05-17T14:27:36.845936+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
2023-05-17T14:27:36.845936+00:00 app[web.1]: response = view_func(request, *args, **kwargs)
2023-05-17T14:27:36.845936+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/views.py", line 63, in dispatch
2023-05-17T14:27:36.845936+00:00 app[web.1]: return super().dispatch(request, *args, **kwargs)
2023-05-17T14:27:36.845936+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
2023-05-17T14:27:36.845936+00:00 app[web.1]: return handler(request, *args, **kwargs)
2023-05-17T14:27:36.845936+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/views/generic/edit.py", line 142, in post
2023-05-17T14:27:36.845937+00:00 app[web.1]: return self.form_valid(form)
2023-05-17T14:27:36.845937+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/views.py", line 92, in form_valid
2023-05-17T14:27:36.845937+00:00 app[web.1]: auth_login(self.request, form.get_user())
2023-05-17T14:27:36.845937+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/__init__.py", line 108, in login
2023-05-17T14:27:36.845937+00:00 app[web.1]: request.session.cycle_key()
2023-05-17T14:27:36.845938+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 344, in cycle_key
2023-05-17T14:27:36.845938+00:00 app[web.1]: self.create()
2023-05-17T14:27:36.845938+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/db.py", line 55, in create
2023-05-17T14:27:36.845938+00:00 app[web.1]: self.save(must_create=True)
2023-05-17T14:27:36.845938+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/db.py", line 87, in save
2023-05-17T14:27:36.845938+00:00 app[web.1]: obj.save(force_insert=must_create, force_update=not must_create, using=using)
2023-05-17T14:27:36.845939+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 753, in save
2023-05-17T14:27:36.845939+00:00 app[web.1]: self.save_base(using=using, force_insert=force_insert,
2023-05-17T14:27:36.845939+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 790, in save_base
2023-05-17T14:27:36.845939+00:00 app[web.1]: updated = self._save_table(
2023-05-17T14:27:36.845939+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 895, in _save_table
2023-05-17T14:27:36.845939+00:00 app[web.1]: results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
2023-05-17T14:27:36.845940+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 933, in _do_insert
2023-05-17T14:27:36.845940+00:00 app[web.1]: return manager._insert(
2023-05-17T14:27:36.845940+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
2023-05-17T14:27:36.845940+00:00 app[web.1]: return getattr(self.get_queryset(), name)(*args, **kwargs)
2023-05-17T14:27:36.845940+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 1254, in _insert
2023-05-17T14:27:36.845940+00:00 app[web.1]: return query.get_compiler(using=using).execute_sql(returning_fields)
2023-05-17T14:27:36.845940+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1397, in execute_sql
2023-05-17T14:27:36.845940+00:00 app[web.1]: cursor.execute(sql, params)
2023-05-17T14:27:36.845945+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
2023-05-17T14:27:36.845945+00:00 app[web.1]: return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
2023-05-17T14:27:36.845945+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
2023-05-17T14:27:36.845945+00:00 app[web.1]: return executor(sql, params, many, context)
2023-05-17T14:27:36.845946+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
2023-05-17T14:27:36.845946+00:00 app[web.1]: return self.cursor.execute(sql, params)
2023-05-17T14:27:36.845946+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
2023-05-17T14:27:36.845946+00:00 app[web.1]: raise dj_exc_value.with_traceback(traceback) from exc_value
2023-05-17T14:27:36.845946+00:00 app[web.1]: File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
2023-05-17T14:27:36.845946+00:00 app[web.1]: return self.cursor.execute(sql, params)
2023-05-17T14:27:36.845947+00:00 app[web.1]: django.db.utils.ProgrammingError: permission denied for table django_session
2023-05-17T14:27:36.845947+00:00 app[web.1]:

note these two errors:

i'm not sure why we're getting an permission denied error for the django_session table. the latest code changes haven't touched that.

smcalilly commented 1 year ago

ah, we've reached our limit for the staging database plan:

heroku pg:info -a ccfp-asset-dashboard-staging                                                            sammcalilly@dm
=== DATABASE_URL
Plan:                  Mini
Status:                Available
Connections:           0/20
PG Version:            15.3
Created:               2021-01-04 21:00 UTC
Data Size:             26.4 MB/1.00 GB (In compliance)
Tables:                34
Rows:                  10033/10000 (Write access revoked)
Fork/Follow:           Unsupported
Rollback:              Unsupported
Continuous Protection: Off
Add-on:                postgresql-convex-65698
smcalilly commented 1 year ago

fixed by upgrading the basic plan, following this guide: https://devcenter.heroku.com/articles/upgrading-heroku-postgres-databases