Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntegrityError when fs-type plugin instance finishes where feed is shared with another user #603

Open
jennydaman opened this issue Jan 17, 2025 · 0 comments
Labels

Comments

@jennydaman
Copy link
Contributor

jennydaman commented Jan 17, 2025

  1. Set up CUBE with two users, e.g. bobb and alice.
  2. As user bobb, create a fs-type plugin instance which runs for at least 60 seconds, e.g. pl-simplefsapp ... --sleepLength 60
  3. Share the feed with (i.e. create a Userpermission for the feed for) user alice.
  4. When the plugin instance finishes, the worker spits out this error:
[2025-01-17 00:13:19,422] [INFO][plugininstances.services.manager][manager.py:667 save_plugin_instance_final_status] Setting output folder's permissions for job chris-jid-3 ...
[2025-01-17 00:13:19,430] [ERROR][trace 9 136815613015872] Task plugininstances.tasks.check_plugin_instance_exec_status[0de5b5c7-937f-4535-915a-2d3ea57eaed1] raised unexpected: IntegrityError('duplicate key value violates unique constraint "core_folderuserpermission_folder_id_user_id_8870905f_uniq"\nDETAIL:  Key (folder_id, user_id)=(23, 2) already exists.')
Traceback (most recent call last):
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)
psycopg.errors.UniqueViolation: duplicate key value violates unique constraint "core_folderuserpermission_folder_id_user_id_8870905f_uniq"
DETAIL:  Key (folder_id, user_id)=(23, 2) already exists.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/app-root/lib64/python3.11/site-packages/celery/app/trace.py", line 477, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/app-root/src/plugininstances/tasks.py", line 59, in check_plugin_instance_exec_status
    plg_inst_manager.check_plugin_instance_app_exec_status()
  File "/opt/app-root/src/plugininstances/services/manager.py", line 315, in check_plugin_instance_app_exec_status
    self._handle_finished_successfully_status()
  File "/opt/app-root/src/plugininstances/services/manager.py", line 938, in _handle_finished_successfully_status
    self.save_plugin_instance_final_status()
  File "/opt/app-root/src/plugininstances/services/manager.py", line 673, in save_plugin_instance_final_status
    self.c_plugin_inst.output_folder.parent.grant_user_permission(user, 'w')
  File "/opt/app-root/src/core/models.py", line 213, in grant_user_permission
    FolderUserPermission.objects.create(folder=self, user=user, permission=permission)
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/models/query.py", line 658, in create
    obj.save(force_insert=True, using=self.db)
  File "/opt/app-root/src/core/models.py", line 447, in save
    super(FolderUserPermission, self).save(*args, **kwargs)
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/models/base.py", line 814, in save
    self.save_base(
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/models/base.py", line 877, in save_base
    updated = self._save_table(
              ^^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/models/base.py", line 1020, in _save_table
    results = self._do_insert(
              ^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/models/base.py", line 1061, in _do_insert
    return manager._insert(
           ^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/models/query.py", line 1805, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/models/sql/compiler.py", line 1822, in execute_sql
    cursor.execute(sql, params)
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/backends/utils.py", line 102, in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/app-root/lib64/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/app-root/lib64/python3.11/site-packages/psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "core_folderuserpermission_folder_id_user_id_8870905f_uniq"
DETAIL:  Key (folder_id, user_id)=(23, 2) already exists.
@jennydaman jennydaman added the bug label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant