Opened 11 years ago

Closed 11 years ago

#616 closed defect (fixed)

Deleting user account crashes if you have attachements on your media

Reported by: joar Owned by: Elrond
Priority: critical Milestone: 0.3.3
Component: programming Keywords: sql
Cc: Elrond, joar Parent Tickets:


File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/Paste-', line 144 in __call__
  app_iter = self.application(environ, sr_checker)
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/Paste-', line 203 in __call__
  return app(environ, start_response)
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/Beaker-1.6.3-py2.7.egg/beaker/', line 155 in __call__
  return self.wrap_app(environ, session_start_response)
File '/home/joar/git/mediagoblin/mediagoblin/', line 236 in __call__
  return self.call_backend(environ, start_response)
File '/home/joar/git/mediagoblin/mediagoblin/', line 216 in call_backend
  response = controller(request)
File '/home/joar/git/mediagoblin/mediagoblin/', line 48 in new_controller_func
  return controller(request, *args, **kwargs)
File '/home/joar/git/mediagoblin/mediagoblin/edit/', line 277 in delete_account
File '/home/joar/git/mediagoblin/mediagoblin/db/', line 93 in delete
  media.delete(del_orphan_tags=False, commit=False)
File '/home/joar/git/mediagoblin/mediagoblin/db/', line 251 in delete
  for comment in self.get_comments():
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/orm/', line 2226 in __iter__
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/orm/', line 1012 in _autoflush
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/orm/', line 1583 in flush
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/orm/', line 1654 in _flush
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/orm/', line 331 in execute
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/orm/', line 475 in execute
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/orm/', line 59 in save_obj
  mapper, table, update)
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/orm/', line 485 in _emit_update_statements
  execute(statement, params)
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/engine/', line 1449 in execute
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/engine/', line 1584 in _execute_clauseelement
  compiled_sql, distilled_params
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/engine/', line 1698 in _execute_context
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/engine/', line 1691 in _execute_context
File '/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg/sqlalchemy/engine/', line 331 in do_execute
  cursor.execute(statement, parameters)
IntegrityError: (IntegrityError) core__attachment_files.media_entry may not be NULL u'UPDATE core__attachment_files SET media_entry=? WHERE = ?' (None, 2)

Change History (4)

comment:1 by Christopher Allan Webber, 11 years ago

So, I think there's some question about how we handle cascading deletes. This is both an issue for MediaEntries, and it's an issue for here.

Assuming we do the .delete() of a user, what about the other things that need to happen for each of their media entries? That is to say, deleting each of their media entries' files as well.

What I think is we probably need to do this: Deleting a user sets up a celery task with a series of subtasks for each media deletion. This way there isn't an http timeout as a bunch of files are potentially deleted from disk (which would be totally wonky)

So, this wouldn't be relying on the de-facto cascading delete code of sqlalchemy. (Also, I'll note that cascading deletes are just going to get more and more complex as we go the way of the plugin..)

comment:2 by Christopher Allan Webber, 11 years ago

Cc: Elrond joar added

comment:3 by Elrond, 11 years ago

Owner: set to Elrond
Status: newaccepted

Okay, because I wanted to reproduce another error that joar found, I wrote a unit test and then fixed both. It's in a local tree, just wanted to take the bug, so that nobody else needs to invest time.

News at 10.

comment:4 by Elrond, 11 years ago

Resolution: fixed
Status: acceptedclosed

Should be fixed with df5b142ab9bfc590f17768079104f6cfa2cd7bba.

Note: See TracTickets for help on using tickets.