Skip to content
GitLab
Next
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • gitaly gitaly
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 561
    • Issues 561
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 56
    • Merge requests 56
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • gitalygitaly
  • Merge requests
  • !2749

Create database records for repositories missing them

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Sami Hiltunen requested to merge smh-migration-tool into master Nov 04, 2020
  • Overview 38
  • Commits 2
  • Pipelines 9
  • Changes 8

In the past, Praefect did not create a database records for hosted repositories. Nowadays Praefect tracks repositories and the storage's hosting copies of them in the repositories and the storage_repositorie tables. Various components in Praefect, including the automatic reconciler, operate only based on these database records. As such, repositories which have received no mutators after the introduction of the tables are ignored.

There are two work in progress features in the pipeline that also depend on the database records.

  1. Repository specific primaries need to know which repositories exist in order to elect a primary for them.
  2. Variable replication factor needs to know which storage locations contain the repository in order to route the requests to correct nodes.

This commit adds support for creating database records for repositories which are still missing them. The importer walks the primary storage of each virtual storage and creates a record for each repository existing on the primary. The created records can then be picked up by the automatic reconciler which will replicate the repositories to the secondaries and create their records.

Repositories on secondaries are ignored by the importer. This matches how Praefect would behave in general. If a repository is missing database records and it receives a write, Praefect follows it's previous behavior and simply accepts the write and overwrites the copies on the secondaries.

Once the migration has been successfully completed, a flag in the database is set to prevent the migration from running again unnecessarily. If the importer does not run to completion, it is safe to rerun. Running the importer concurrently is also safe as only missing records are added and existing ones are unmodified.

The import runs on each Praefect node on start up and retries on every restart until it has successfully completed.

Closes #3033 (closed)

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: smh-migration-tool