You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Duplicate key issues in database for PublicContact in stable.
Instances of bug in logs:
Dec 26, 2024 @ 18:38:13.547 /domain/12821
Jan 6, 2025 @ 08:06:14.790 /domain/13059
Stack trace for reference:
Traceback (most recent call last):
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "registrar_publiccontact_contact_type_registry_id_4542e191_uniq"
DETAIL: Key (contact_type, registry_id, domain_id)=(admin, MoTa5H3fL5PI5Ub3, 13059) already exists.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/vcap/deps/0/python/lib/python3.10/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view
return self.dispatch(request, *args, **kwargs)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch
return handler(request, *args, **kwargs)
File "/home/vcap/app/registrar/views/domain.py", line 81, in get
context = self.get_context_data(object=self.object)
File "/home/vcap/app/registrar/views/domain.py", line 268, in get_context_data
security_email = self.object.get_security_email()
File "/home/vcap/app/registrar/models/domain.py", line 1004, in get_security_email
security_contact = self.generic_contact_getter(security)
File "/home/vcap/app/registrar/models/domain.py", line 1289, in generic_contact_getter
contacts = self._get_property(desired_property)
File "/home/vcap/app/registrar/models/domain.py", line 2128, in _get_property
self._fetch_cache(
File "/home/vcap/app/registrar/models/domain.py", line 1882, in _fetch_cache
self._update_hosts_and_contacts(cleaned, fetch_hosts, fetch_contacts)
File "/home/vcap/app/registrar/models/domain.py", line 1945, in _update_hosts_and_contacts
cleaned["contacts"] = self._get_contacts(cleaned.get("_contacts", []))
File "/home/vcap/app/registrar/models/domain.py", line 2050, in _get_contacts
cleaned_contacts = self._fetch_contacts(contacts)
File "/home/vcap/app/registrar/models/domain.py", line 1668, in _fetch_contacts
in_db = self._get_or_create_public_contact(mapped_object)
File "/home/vcap/app/registrar/models/domain.py", line 2089, in _get_or_create_public_contact
public_contact.save(skip_epp_save=True)
File "/home/vcap/app/registrar/models/public_contact.py", line 53, in save
super().save(*args, **kwargs)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/models/base.py", line 814, in save
self.save_base(
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/models/base.py", line 877, in save_base
updated = self._save_table(
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/models/base.py", line 1020, in _save_table
results = self._do_insert(
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/models/base.py", line 1061, in _do_insert
return manager._insert(
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/models/query.py", line 1805, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1822, in execute_sql
cursor.execute(sql, params)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
with self.db.wrap_database_errors:
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "registrar_publiccontact_contact_type_registry_id_4542e191_uniq"
DETAIL: Key (contact_type, registry_id, domain_id)=(admin, MoTa5H3fL5PI5Ub3, 13059) already exists.
AC
investigate this bug (see the slack thread for more context and the logs in kibana)
determine the cause of the bug and implement a fix
Additional details
We have had this issue pop up a few times before, so I think the issue is coming from our PublicContact model, I would evaluate this model and it's relation with domain.py as part of this investigation. A refactor may be needed.
Duplicate key issues in database for PublicContact in stable.
Instances of bug in logs:
Dec 26, 2024 @ 18:38:13.547 /domain/12821
Jan 6, 2025 @ 08:06:14.790 /domain/13059
Stack trace for reference:
AC
Additional details
We have had this issue pop up a few times before, so I think the issue is coming from our PublicContact model, I would evaluate this model and it's relation with domain.py as part of this investigation. A refactor may be needed.
slack thread with more context on this bug
The text was updated successfully, but these errors were encountered: