From a377d7a624963fdb5ffa4fb614fa6f763e2054cb Mon Sep 17 00:00:00 2001 From: ChrisBAshton Date: Sun, 7 Jul 2024 12:19:26 +0100 Subject: [PATCH] Reset Content Store `payload_version` to 0 in non-prod envs Occasionally, Content Store and Publishing API can fall out of sync in non-production environments after the environment sync process has completed. Content Store can be a day 'ahead' of Publishing API. Consequently, any publish events from Publishing API in the affected environment will be rejected by Content Store, if the `Event.maximum_id` in Publishing API is behind the `payload_version` of the `ContentItem` being updated in Content Store. The pragmatic fix is to reset the `payload_version` in Content Store so that it can never be ahead of Publishing API. --- charts/db-backup/scripts/content-store.sql | 17 +++++++++++++++++ charts/db-backup/values.yaml | 4 ++++ 2 files changed, 21 insertions(+) create mode 100644 charts/db-backup/scripts/content-store.sql diff --git a/charts/db-backup/scripts/content-store.sql b/charts/db-backup/scripts/content-store.sql new file mode 100644 index 00000000000..d1f2ca8b921 --- /dev/null +++ b/charts/db-backup/scripts/content-store.sql @@ -0,0 +1,17 @@ +-- sqlfluff:dialect:mysql + +-- Occasionally, Content Store and Publishing API can fall out of +-- sync in non-production environments after the environment sync +-- process has completed. Content Store can be a day 'ahead' of +-- Publishing API. +-- +-- Consequently, any publish events from Publishing API in the +-- affected environment will be rejected by Content Store, if the +-- `Event.maximum_id` in Publishing API is behind the +-- `payload_version` of the `ContentItem` being updated in Content +-- Store. +-- +-- The pragmatic fix is to reset the `payload_version` in Content +-- Store so that it can never be ahead of Publishing API. +UPDATE content_items +SET payload_version = 0; diff --git a/charts/db-backup/values.yaml b/charts/db-backup/values.yaml index 7069db4d4ff..6310885c93b 100644 --- a/charts/db-backup/values.yaml +++ b/charts/db-backup/values.yaml @@ -334,6 +334,8 @@ cronjobs: operations: - op: restore bucket: s3://govuk-production-database-backups + - op: transform + script: content-store.sql - op: backup draft-content-store-postgres: <<: *s5cmd-ram-workaround @@ -342,6 +344,8 @@ cronjobs: operations: - op: restore bucket: s3://govuk-production-database-backups + - op: transform + script: content-store.sql - op: backup content-tagger-postgres: