Uploaded image for project: 'The Virtual Brain'
  1. The Virtual Brain
  2. TVB-2930

Can't delete project containing links with Postgres

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2
    • Fix Version/s: 2.4
    • Component/s: TVB Framework
    • Labels:
      None
    • Epic Link:
    • Sprint:
      VBC Sprint 13
    • TVB-C Task:
      8.2 Pipeline Integration

      Description

      The simplest way to reproduce this is to use the Default Project as it is and create a new project. The Default Project has to contain at least one link towards the new project (a datatype like Region Mapping which depends on other datatypes). When you delete the Default Project, the following error will appear:

      The above exception was the direct cause of the following exception:
      
      Traceback (most recent call last):
        File "c:\users\robert.vincze\documents\tvb-root\framework_tvb\tvb\core\entities\storage\root_dao.py", line 118, in remove_entity
          self.session.commit()
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\session.py", line 1423, in commit
          self._transaction.commit(_to_root=self.future)
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\session.py", line 829, in commit
          self._prepare_impl()
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\session.py", line 808, in _prepare_impl
          self.session.flush()
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\session.py", line 3255, in flush
          self._flush(objects)
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\session.py", line 3395, in _flush
          transaction.rollback(_capture_exception=True)
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\util\langhelpers.py", line 72, in __exit__
          with_traceback=exc_tb,
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\util\compat.py", line 211, in raise_
          raise exception
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\session.py", line 3355, in _flush
          flush_context.execute()
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 450, in execute
          n.execute_aggregate(self, set_)
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 774, in execute_aggregate
          mapper, [s for s in states if uow.states[s][0]], uow
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\persistence.py", line 345, in delete_obj
          delete,
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\persistence.py", line 1441, in _emit_delete_statements
          statement, del_objects, execution_options=execution_options
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\engine\base.py", line 1521, in _execute_20
          return meth(self, args_10style, kwargs_10style, execution_options)
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\sql\elements.py", line 314, in _execute_on_connection
          self, multiparams, params, execution_options
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\engine\base.py", line 1400, in _execute_clauseelement
          cache_hit=cache_hit,
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\engine\base.py", line 1750, in _execute_context
          e, statement, parameters, cursor, context
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\engine\base.py", line 1931, in _handle_dbapi_exception
          sqlalchemy_exception, with_traceback=exc_info[2], from_=e
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\util\compat.py", line 211, in raise_
          raise exception
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\engine\base.py", line 1707, in _execute_context
          cursor, statement, parameters, context
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\engine\default.py", line 716, in do_execute
          cursor.execute(statement, parameters)
      sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) update or delete on table "HasTraitsIndex" violates foreign key constraint "RegionMappingIndex_fk_surface_gid_fkey" on table "RegionMappingIndex"
      DETAIL:  Key (gid)=(10467c4fd4874186afa6d9b1fd8383d8) is still referenced from table "RegionMappingIndex".
      
      [SQL: DELETE FROM "HasTraitsIndex" WHERE "HasTraitsIndex".id = %(id)s]
      [parameters: {'id': 2}]
      (Background on this error at: http://sqlalche.me/e/14/gkpj)
      2021-05-21 16:23:27,436 - ERROR - tvb.interface.web.controllers.decorators - An unexpected exception appeared
      Traceback (most recent call last):
        File "c:\users\robert.vincze\documents\tvb-root\framework_tvb\tvb\interfaces\web\controllers\decorators.py", line 153, in deco
          return func(*a, **b)
        File "c:\users\robert.vincze\documents\tvb-root\framework_tvb\tvb\interfaces\web\controllers\decorators.py", line 81, in deco
          template_dict = func(*a, **b)
        File "c:\users\robert.vincze\documents\tvb-root\framework_tvb\tvb\interfaces\web\controllers\decorators.py", line 200, in deco
          return func(*a, **b)
        File "c:\users\robert.vincze\documents\tvb-root\framework_tvb\tvb\interfaces\web\controllers\decorators.py", line 272, in deco
          return func(*a, **b)
        File "c:\users\robert.vincze\documents\tvb-root\framework_tvb\tvb\interfaces\web\controllers\project\project_controller.py", line 160, in editone
          self._remove_project(project_id)
        File "c:\users\robert.vincze\documents\tvb-root\framework_tvb\tvb\interfaces\web\controllers\project\project_controller.py", line 141, in _remove_project
          self.project_service.remove_project(project_id)
        File "c:\users\robert.vincze\documents\tvb-root\framework_tvb\tvb\core\entities\storage\session_maker.py", line 354, in dec
          session_maker.close_transaction()
        File "c:\users\robert.vincze\documents\tvb-root\framework_tvb\tvb\core\entities\storage\session_maker.py", line 326, in close_transaction
          self.handled_sessions[current_thread].close_transaction()
        File "c:\users\robert.vincze\documents\tvb-root\framework_tvb\tvb\core\entities\storage\session_maker.py", line 239, in close_transaction
          top_transaction_session.commit()
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\session.py", line 1423, in commit
          self._transaction.commit(_to_root=self.future)
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\orm\session.py", line 836, in commit
          trans.commit()
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\engine\base.py", line 2266, in commit
          self._do_commit()
        File "c:\users\robert.vincze\anaconda3\envs\storage-tvb\lib\site-packages\sqlalchemy\engine\base.py", line 2459, in _do_commit
          raise exc.InvalidRequestError("This transaction is inactive")
      sqlalchemy.exc.InvalidRequestError: This transaction is inactive
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                robert.vincze Robert Francisc Vincze
                Reporter:
                robert.vincze Robert Francisc Vincze
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 4 hours
                    4h
                    Remaining:
                    Time Spent - 2 hours Remaining Estimate - 2 hours
                    2h
                    Logged:
                    Time Spent - 2 hours Remaining Estimate - 2 hours
                    2h