Skip to content

IntegrityError: duplicate key value violates unique constraint "contentcuration_contentnode_tags_contentnode_id_c... #4221

Closed

Description

@sentry

Occurred when copying files from the clipboard into a channel. The resources copied but the tags failed to copy and caused issues in the UI


Sentry Issue: STUDIO-GHK

UniqueViolation: duplicate key value violates unique constraint "contentcuration_contentnode_tags_contentnode_id_cfa67da1_uniq"
DETAIL:  Key (contentnode_id, contenttag_id)=(9472cb5d6e1a47aeb5c4145f66d53146, 87538e2cbd204993a7f4de0ff4b8f8bc) already exists.

  File "django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "django_prometheus/db/common.py", line 71, in execute
    return super().execute(*args, **kwargs)

IntegrityError: duplicate key value violates unique constraint "contentcuration_contentnode_tags_contentnode_id_cfa67da1_uniq"
DETAIL:  Key (contentnode_id, contenttag_id)=(9472cb5d6e1a47aeb5c4145f66d53146, 87538e2cbd204993a7f4de0ff4b8f8bc) already exists.

(14 additional frame(s) were not displayed)
...
  File "contentcuration/db/models/manager.py", line 383, in copy_node
    return self._copy(
  File "contentcuration/db/models/manager.py", line 413, in _copy
    copied_nodes = self._deep_copy(
  File "contentcuration/db/models/manager.py", line 641, in _deep_copy
    self._copy_associated_objects(source_copy_id_map)
  File "contentcuration/db/models/manager.py", line 563, in _copy_associated_objects
    self._copy_tags(source_copy_id_map)
  File "contentcuration/db/models/manager.py", line 502, in _copy_tags
    self.model.tags.through.objects.bulk_create(mappings_to_create)

Activity

  1. self-assigned this
    on Jul 18, 2023
  2. rtibbles commented on Jul 19, 2023

    @rtibbles
    Member

    I have observed some duplicated copy events in the Change table for the channel here - although, it doesn't seem to be for copy target that caused this error, oddly.

    I think handling this error more gracefully (because if it is already copied, our work is done!) plus preventing duplicate copy events should be sufficient to resolve this error.

  3. rtibbles commented on Jul 19, 2023

    @rtibbles
    Member

    I wasn't able to reproduce any duplicated copy events - so not entirely sure what is happening here.

  4. rtibbles commented on Jul 19, 2023

    @rtibbles
    Member

    Fixed in #4232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0 - criticalPriority: Release blocker or regression

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions