Fix foreign key error while backfilling

What does this MR do and why?

Fix foreign key error while backfilling

The foreign key constraints on parent_id on namespaces table has 'NOT VALID' clause. This means there can be old records which is not valid, and has parent_id that does not exists in database records.

This MR fixes the Background Migration to handle such records by existing if user_id and root_namespace_id already exists.

At the same time as detecting the foreign key error, we also identified that too many records were being created in the table.

We've rectified the problem in !174563 (merged) and so now we can truncate the table to remove all rows (rather than trying to identify which are invalid and conditionally removing).

So in summary, this MR:

  1. Fixes the backfill background migration to handle foreign key related errors
  2. Truncates the subscription_seat_assignments table to remove all rows
  3. Re-enqueues the backfill to start again

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

  • #482392+

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  • Additional specs for missing user_id and namespace_id
Edited by Vijay Hawoldar

Merge request reports

Loading