Skip to content

Make repository ID non nullable

Sami Hiltunen requested to merge smh-delete-orphaned-records into master

Praefect is setting the repository_id column since 14.3. 14.4 included a migration to backfill all records with a valid repository_id. The only remaining case where repository ID could be null is orphaned replica records in storage_repositories after a repository is deleted. In 14.5, Praefect no longer leaves these orphaned records behind but deletes all repositories in the one go. As there are no cases where the repository ID can be null anymore, this commit makes the schema stricter and sets repository ID to be non-null in both storage_repositories and repository_assignments. As there may still be some old orphaned replica records in storage_repositories, this commit removes them prior to applying the constraint. The orphaned replicas should already have a delete job in flight from the original RemoveRepository RPC call. It's possible some orphaned replicas are left on the disks. These will be picked up later by Praefect's crawler that goes through storages looking for unneeded repositories. In 14.6, these won't cause any problems either as repositories will have unique relative paths generated by Praefect.

Some tests that did not set up repository ID were updated to set up the IDs as they'd fail otherwise with this change.

Changelog: changed

Merge request reports