I've been getting 500 errors recently on website. The error is ProgrammingError: permission denied for relation django_session
.
It happens at times with update_disable()
ajax function.
Here is the function
def update_disable(request, song_pk, dj_name=None, view=None, genre=None):
song = Song.objects.get(pk=song_pk)
song.votes = song.votes + 1
song.save()
dajax = Dajax()
dajax.assign('.vote', 'disabled', 'disabled')
if dj_name:
request.session[dj_name] = True
elif genre:
print genre
request.session[genre] = True
else:
if view=="month":
request.session['month_voted'] = True
else:
request.session['trending_voted'] = True
request.session.set_expiry(604800)
visitor = get_obj_or_none(Visitor, last_session_key=request.session._session_key)
if visitor:
voter = get_obj_or_none(Voter, visitor=visitor)
if voter:
voter.vote_count += 1
voter.save()
else:
voter = Voter(visitor=visitor)
voter.save()
return dajax.json()
I can't seem to understand what's throwing this error. Any idea?
Here is the entire traceback
Traceback (most recent call last):
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 201, in get_response
response = middleware_method(request, response)
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/sessions/middleware.py", line 38, in process_response
request.session.save()
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py", line 63, in save
obj.save(force_insert=must_create, using=using)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/base.py", line 545, in save
force_update=force_update, update_fields=update_fields)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/base.py", line 573, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/base.py", line 654, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/base.py", line 687, in _do_insert
using=using, raw=raw)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/manager.py", line 232, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/query.py", line 1511, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 899, in execute_sql
cursor.execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
ProgrammingError: permission denied for relation django_session
<WSGIRequest
path:/dajaxice/hunt.update_disable/,
GET:<QueryDict: {}>,
POST:<QueryDict: {u'argv': [u'{"song_pk":"680","dj_name":"Tiesto"}']}>,
COOKIES:{'_ga': 'GA1.2.1299003573.1404006039',
'csrftoken': '**masked**'},
META:{'CONTENT_LENGTH': '67',
'CONTENT_TYPE': 'application/x-www-form-urlencoded',
u'CSRF_COOKIE': u'**masked**',
'HTTP_ACCEPT': '*/*',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',
'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',
'HTTP_CONNECTION': 'close',
'HTTP_COOKIE': 'csrftoken=**masked**; _ga=GA1.2.1299003573.1404006039',
'HTTP_HOST': 'www.edmhunters.com',
'HTTP_ORIGIN': 'http://www.edmhunters.com',
'HTTP_REFERER': 'http://www.edmhunters.com/top100/tiesto/',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36',
'HTTP_X_CSRFTOKEN': '**masked**',
'HTTP_X_FORWARDED_FOR': '110.32.33.39',
'HTTP_X_FORWARDED_PORT': '80',
'HTTP_X_FORWARDED_PROTO': 'http',
'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest',
'HTTP_X_REQUEST_ID': 'ebadfe5f-d375-460d-8bdf-8a879f8fb13b',
'HTTP_X_REQUEST_START': '1404006080594',
'PATH_INFO': u'/dajaxice/hunt.update_disable/',
'QUERY_STRING': '',
'RAW_URI': '/dajaxice/hunt.update_disable/',
'REMOTE_ADDR': '10.122.102.62',
'REMOTE_PORT': '34465',
'REQUEST_METHOD': 'POST',
'SCRIPT_NAME': u'',
'SERVER_NAME': 'www.edmhunters.com',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SOFTWARE': 'gunicorn/18.0',
'gunicorn.socket': <socket._socketobject object at 0x35882f0>,
'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7fcd37a971e0>,
'wsgi.file_wrapper': <class gunicorn.http.wsgi.FileWrapper at 0x244e1f0>,
'wsgi.input': <gunicorn.http.body.Body object at 0x35bc550>,
'wsgi.multiprocess': False,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)}>
If you're using Heroku PostgreSQL as your database, it's possible you've reached the row limit. Verify it with the command line tool:
heroku pg:info -a <your_app>
=== HEROKU_POSTGRESQL_MAUVE_URL, DATABASE_URL
Plan: Hobby-dev
Status: Available
Connections: 0/20
PG Version: 10.6
Created: 2018-03-14 22:04 UTC
Data Size: 20.3 MB
Tables: 90
Rows: 13764/10000 (Write access revoked)
Fork/Follow: Unsupported
Rollback: Unsupported
Continuous Protection: Off
Billing App: xxxxxxxxx
Add-on: postgresql-silhouetted-xxx
The Rows:
row tells you that the write access has been revoked: (Write access revoked)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With