failed to delete uses when user has pending pull requests to review

joe's Avatar

joe

26 Aug, 2014 06:04 PM

RhodeCode version:
2.2.4 Python version:
2.7.7

I get a generic failure when a user has a pending pull request to review and an admin tries to delete them. full stack trace follows.

[Tue Aug 26 17:59:03 2014] [error] 
[Tue Aug 26 17:59:03 2014] [error] 2014-08-26 17:59:03.996 ERROR [rhodecode.controllers.admin.users] Traceback (most recent call last):
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/rhodecode/controllers/admin/users.py", line 219, in delete
[Tue Aug 26 17:59:03 2014] [error]     UserModel().delete(usr)
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/rhodecode/model/user.py", line 281, in delete
[Tue Aug 26 17:59:03 2014] [error]     log_delete_user(user.get_dict(), cur_user)
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/rhodecode/model/db.py", line 92, in get_dict
[Tue Aug 26 17:59:03 2014] [error]     json_attr = json_attr()
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/rhodecode/model/db.py", line 656, in _json_
[Tue Aug 26 17:59:03 2014] [error]     data.update(self.get_api_data())
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/rhodecode/model/db.py", line 637, in get_api_data
[Tue Aug 26 17:59:03 2014] [error]     emails=user.emails,
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/rhodecode/model/db.py", line 456, in emails
[Tue Aug 26 17:59:03 2014] [error]     other = UserEmailMap.query().filter(UserEmailMap.user==self).all()
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2115, in all
[Tue Aug 26 17:59:03 2014] [error]     return list(self)
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/rhodecode/lib/caching_query.py", line 83, in iter
[Tue Aug 26 17:59:03 2014] [error]     return Query.__iter__(self)
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2226, in iter
[Tue Aug 26 17:59:03 2014] [error]     self.session._autoflush()
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1127, in autoflush
[Tue Aug 26 17:59:03 2014] [error]     self.flush()
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1734, in flush
[Tue Aug 26 17:59:03 2014] [error]     self._flush(objects)
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1805, in flush
[Tue Aug 26 17:59:03 2014] [error]     flush_context.execute()
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 331, in execute
[Tue Aug 26 17:59:03 2014] [error]     rec.execute(self)
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 498, in execute
[Tue Aug 26 17:59:03 2014] [error]     uow
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 115, in delete_obj
[Tue Aug 26 17:59:03 2014] [error]     cachedconnections, mapper, table, delete)
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 671, in _emit_delete_statements
[Tue Aug 26 17:59:03 2014] [error]     connection.execute(statement, del_objects)
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1449, in execute
[Tue Aug 26 17:59:03 2014] [error]     params)
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1584, in _executeclauseelement
[Tue Aug 26 17:59:03 2014] [error]     compiled_sql, distilled_params
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1698, in execute_context
[Tue Aug 26 17:59:03 2014] [error]     context)
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1691, in _execute_context
[Tue Aug 26 17:59:03 2014] [error]     context)
[Tue Aug 26 17:59:03 2014] [error]   File "/var/lib/c4services/rhodecode/env/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 331, in do_execute
[Tue Aug 26 17:59:03 2014] [error]     cursor.execute(statement, parameters)
[Tue Aug 26 17:59:03 2014] [error] IntegrityError: (IntegrityError) update or delete on table "users" violates foreign key constraint "pullrequest_reviewers_user_id_fkey" on table "pull_request_reviewers"
[Tue Aug 26 17:59:03 2014] [error] DETAIL:  Key (user_id)=(47) is still referenced from table "pull_request_reviewers".
[Tue Aug 26 17:59:03 2014] [error]  'DELETE FROM users WHERE users.user_id = %(user_id)s' {'user_id': 47}
  1. Support Staff 1 Posted by Marcin Kuzminsk... on 26 Aug, 2014 06:09 PM

    Marcin Kuzminski's Avatar

    Hi,

    Thanks for posting this, we'll investigate this how to make proper cleanups in such case.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac