django-filer icon indicating copy to clipboard operation
django-filer copied to clipboard

rare `Deadlock found when trying to get lock; try restarting transaction` when uploading

Open benzkji opened this issue 6 years ago • 5 comments

This doesnt normaly happen, and I cant say when exactly it happens, I only get these in Sentry and exception e-mails... Also, clients havent complained yet about anything not working, so it might be one of those "nervous double clicking somewhere" issues. Nevertheless, throws an exception.

OperationalError at /de/admin/filer/clipboard/operations/upload/1/
(1213, 'Deadlock found when trying to get lock; try restarting transaction')

filer 1.3, django 1.11, happens with python 3.5 and 2.7 might be related to one of the dependencies, polymorphic/mptt?

Full traceback:

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py" in execute
  101.             return self.cursor.execute(query, args)

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in execute
  250.             self.errorhandler(self, exc, value)

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/connections.py" in defaulterrorhandler
  50.         raise errorvalue

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in execute
  247.             res = self._query(query)

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in _query
  411.         rowcount = self._do_query(q)

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in _do_query
  374.         db.query(q)

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/connections.py" in query
  277.             _mysql.connection.query(self, query)
  
    
      The above exception ((1213, 'Deadlock found when trying to get lock; try restarting transaction')) was the direct cause of the following exception:
    
  

File "/project/path/virtualenv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/views/decorators/csrf.py" in wrapped_view
  58.         return view_func(*args, **kwargs)

File "/project/path/virtualenv/lib/python3.5/site-packages/filer/admin/clipboardadmin.py" in ajax_upload
  114.             file_obj.save()

File "/project/path/virtualenv/lib/python3.5/site-packages/filer/models/imagemodels.py" in save
  53.         super(Image, self).save(*args, **kwargs)

File "/project/path/virtualenv/lib/python3.5/site-packages/filer/models/abstract.py" in save
  74.         super(BaseImage, self).save(*args, **kwargs)

File "/project/path/virtualenv/lib/python3.5/site-packages/filer/models/filemodels.py" in save
  194.         super(File, self).save(*args, **kwargs)

File "/project/path/virtualenv/lib/python3.5/site-packages/polymorphic/models.py" in save
  74.         return super(PolymorphicModel, self).save(*args, **kwargs)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/models/base.py" in save
  808.                        force_update=force_update, update_fields=update_fields)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/models/base.py" in save_base
  838.             updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/models/base.py" in _save_table
  924.             result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/models/base.py" in _do_insert
  963.                                using=using, raw=raw)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/models/manager.py" in manager_method
  85.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/models/query.py" in _insert
  1076.         return query.get_compiler(using=using).execute_sql(return_id)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql
  1112.                 cursor.execute(sql, params)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/utils.py" in __exit__
  94.                 six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/utils/six.py" in reraise
  685.             raise value.with_traceback(tb)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/project/path/virtualenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py" in execute
  101.             return self.cursor.execute(query, args)

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in execute
  250.             self.errorhandler(self, exc, value)

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/connections.py" in defaulterrorhandler
  50.         raise errorvalue

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in execute
  247.             res = self._query(query)

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in _query
  411.         rowcount = self._do_query(q)

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in _do_query
  374.         db.query(q)

File "/project/path/virtualenv/lib/python3.5/site-packages/MySQLdb/connections.py" in query
  277.             _mysql.connection.query(self, query)

Exception Type: OperationalError at /de/admin/filer/clipboard/operations/upload/1/
Exception Value: (1213, 'Deadlock found when trying to get lock; try restarting transaction')
Request information:

benzkji avatar Mar 28 '18 07:03 benzkji

We have the same issue from time to time.

Could have, based on our observation, something to do with the amount of images uploaded in parallel.

philippeowagner avatar Jun 24 '20 07:06 philippeowagner

did not get it anymore for a very long time now. your assumption seems somehow stringent - processing larger files for example takes some time (calculating sha1, thumbs), so when in the meantime a new file gets uploaded...hm.

benzkji avatar Jun 24 '20 09:06 benzkji

Indeed, file size could be a thing as well.

philippeowagner avatar Jun 24 '20 09:06 philippeowagner

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 28 '22 18:07 stale[bot]

long time no see for this one. how is yours going @philippeowagner ?

benzkji avatar Aug 01 '22 11:08 benzkji

This will now be closed due to inactivity, but feel free to reopen it.

stale[bot] avatar Aug 30 '22 17:08 stale[bot]