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

Publishing the "Facebook Portal Go" product crashes with a locale key unique violation #7821

Closed
Pomax opened this issue Nov 9, 2021 · 1 comment

Comments

@Pomax
Copy link
Contributor

Pomax commented Nov 9, 2021

STR

Running locally with a prod db copy shows:

duplicate key value violates unique constraint "wagtailpages_productpage_translation_key_locale_i_5c988681_uniq"
DETAIL:  Key (translation_key, locale_id)=(9c02feab-2efb-4c6a-ad85-220ea21bd3b7, 1) already exists.

Looking at the tracelog:

postgres_1            | 2021-11-09 23:22:10.137 UTC [51] ERROR:  duplicate key value violates unique constraint "wagtailpages_productpage_translation_key_locale_i_5c988681_uniq"
postgres_1            | 2021-11-09 23:22:10.137 UTC [51] DETAIL:  Key (translation_key, locale_id)=(9c02feab-2efb-4c6a-ad85-220ea21bd3b7, 1) already exists.
postgres_1            | 2021-11-09 23:22:10.137 UTC [51] STATEMENT:  UPDATE "wagtailpages_productpagecategory" SET "translation_key" = '9c02feab-2efb-4c6a-ad85-220ea21bd3b7'::uuid, "locale_id" = 1, "sort_order" = 0, "product_id" = 15283, "category_id" = 2 WHERE "wagtailpages_productpagecategory"."id" = 5512
backend_1             | Internal Server Error: /cms/pages/15283/edit/
backend_1             | Traceback (most recent call last):
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
backend_1             |     return self.cursor.execute(sql, params)
backend_1             | psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "wagtailpages_productpage_translation_key_locale_i_5c988681_uniq"
backend_1             | DETAIL:  Key (translation_key, locale_id)=(9c02feab-2efb-4c6a-ad85-220ea21bd3b7, 1) already exists.
backend_1             |
backend_1             |
backend_1             | The above exception was the direct cause of the following exception:
backend_1             |
backend_1             | Traceback (most recent call last):
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
backend_1             |     response = get_response(request)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response
backend_1             |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
backend_1             |   File "/usr/local/lib/python3.7/contextlib.py", line 74, in inner
backend_1             |     return func(*args, **kwds)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
backend_1             |     response = view_func(request, *args, **kwargs)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/wagtail/admin/urls/__init__.py", line 121, in wrapper
backend_1             |     return view_func(request, *args, **kwargs)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/wagtail/admin/auth.py", line 193, in decorated_view
backend_1             |     return view_func(request, *args, **kwargs)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/views/generic/base.py", line 70, in view
backend_1             |     return self.dispatch(request, *args, **kwargs)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/wagtail/admin/views/pages/edit.py", line 327, in dispatch
backend_1             |     return super().dispatch(request)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/views/generic/base.py", line 98, in dispatch
backend_1             |     return handler(request, *args, **kwargs)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/wagtail/admin/views/pages/edit.py", line 414, in post
backend_1             |     return self.form_valid(self.form)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/wagtail/admin/views/pages/edit.py", line 434, in form_valid
backend_1             |     return self.publish_action()
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/wagtail/admin/views/pages/edit.py", line 492, in publish_action
backend_1             |     previous_revision=(self.previous_revision if self.is_reverting else None)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/wagtail/core/models/__init__.py", line 2570, in publish
backend_1             |     page.save()
backend_1             |   File "/app/network-api/networkapi/wagtailpages/pagemodels/products.py", line 964, in save
backend_1             |     save = super().save(*args, **kwargs)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/wagtail_airtable/mixins.py", line 312, in save
backend_1             |     saved_model = super().save(*args, **kwargs) # Save to database first so we get pk, in case it's used for uniqueness
backend_1             |   File "/usr/local/lib/python3.7/contextlib.py", line 74, in inner
backend_1             |     return func(*args, **kwds)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/wagtail/core/models/__init__.py", line 504, in save
backend_1             |     result = super().save(**kwargs)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/modelcluster/models.py", line 199, in save
backend_1             |     getattr(self, relation).commit()
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/modelcluster/fields.py", line 210, in commit
backend_1             |     original_manager.add(item, bulk=False)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py", line 671, in add
backend_1             |     obj.save()
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/models/base.py", line 754, in save
backend_1             |     force_update=force_update, update_fields=update_fields)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/models/base.py", line 792, in save_base
backend_1             |     force_update, using, update_fields,
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/models/base.py", line 873, in _save_table
backend_1             |     forced_update)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/models/base.py", line 926, in _do_update
backend_1             |     return filtered._update(values) > 0
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/models/query.py", line 803, in _update
backend_1             |     return query.get_compiler(self.db).execute_sql(CURSOR)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1522, in execute_sql
backend_1             |     cursor = super().execute_sql(result_type)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1156, in execute_sql
backend_1             |     cursor.execute(sql, params)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/backends/utils.py", line 98, in execute
backend_1             |     return super().execute(sql, params)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/backends/utils.py", line 66, in execute
backend_1             |     return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
backend_1             |     return executor(sql, params, many, context)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
backend_1             |     return self.cursor.execute(sql, params)
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__
backend_1             |     raise dj_exc_value.with_traceback(traceback) from exc_value
backend_1             |   File "/app/dockerpythonvenv/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
backend_1             |     return self.cursor.execute(sql, params)
backend_1             | django.db.utils.IntegrityError: duplicate key value violates unique constraint "wagtailpages_productpage_translation_key_locale_i_5c988681_uniq"
backend_1             | DETAIL:  Key (translation_key, locale_id)=(9c02feab-2efb-4c6a-ad85-220ea21bd3b7, 1) already exists.
@Pomax
Copy link
Contributor Author

Pomax commented Mar 30, 2022

this got fixed

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

No branches or pull requests

1 participant