Skip to content

Add replica path column to repositories table

Sami Hiltunen requested to merge smh-replica-path into master

Praefect is going to generate unique relative paths for each of the repositories stored on the cluster to avoid stale state from previously deleted repositories affecting new repositories. The relative path generated by Praefect will also be persistent and the repositories will never be moved on disk. This allows Praefect to manage repository renames atomically in the database. To store this generated relative path, this commit introduces the replica_path column which stores for each repository where on the disk its replicas are stored. Each replica of a given repository is stored in the same path, so the new column is added to the repositories table to avoid duplicating the information on each of the storage_repositories records. Once this is in place and the router is using the new column, we can drop the virtual storage and relative path columns from storage_repositories as they duplicate information present in the repositories table.

Once a repository is deleted from the cluster, its entry in the repositories table is going to be removed. That also removes the information of where the replicas are on the disk. This is fine as we'll later have a crawler in place to walk the disks to remove any stale replicas of deleted repositories. The crawler will handle the clean up of any failed deletions which would currently be handled by the reconciler. This also allows us to improve our database schema by adding a foreign key with cascading delete to the repositories table. Once a repository's record is removed, all of the connected records are automatically removed.

As the replica path is currently still the same as the relative path the client uses to access the repository, this commit is only adding the column to the schema and always filling it with the relative path. This allows us to run a migration in a later release to fill the replica path for all existing records without concurrent creations causing problems.

Related to: #3485 (closed)

Edited by Sami Hiltunen

Merge request reports

Loading