Module: Gitlab::BackgroundMigration

Defined in:
lib/gitlab/background_migration.rb,
lib/gitlab/background_migration/logger.rb,
lib/gitlab/background_migration/base_job.rb,
lib/gitlab/background_migration/job_coordinator.rb,
lib/gitlab/background_migration/legacy_upload_mover.rb,
lib/gitlab/background_migration/expire_o_auth_tokens.rb,
lib/gitlab/background_migration/backfill_topics_title.rb,
lib/gitlab/background_migration/batched_migration_job.rb,
lib/gitlab/background_migration/cleanup_orphaned_routes.rb,
lib/gitlab/background_migration/create_security_setting.rb,
lib/gitlab/background_migration/destroy_invalid_members.rb,
lib/gitlab/background_migration/legacy_uploads_migrator.rb,
lib/gitlab/background_migration/migrate_human_user_type.rb,
lib/gitlab/background_migration/re_expire_o_auth_tokens.rb,
lib/gitlab/background_migration/encrypt_ci_trigger_token.rb,
lib/gitlab/background_migration/mailers/unconfirm_mailer.rb,
lib/gitlab/background_migration/backfill_project_settings.rb,
lib/gitlab/background_migration/recount_epic_cache_counts.rb,
lib/gitlab/background_migration/sync_scan_result_policies.rb,
lib/gitlab/background_migration/backfill_environment_tiers.rb,
lib/gitlab/background_migration/backfill_epic_cache_counts.rb,
lib/gitlab/background_migration/backfill_internal_on_notes.rb,
lib/gitlab/background_migration/backfill_issue_search_data.rb,
lib/gitlab/background_migration/backfill_namespace_details.rb,
lib/gitlab/background_migration/backfill_partitioned_table.rb,
lib/gitlab/background_migration/create_vulnerability_links.rb,
lib/gitlab/background_migration/delete_invalid_epic_issues.rb,
lib/gitlab/background_migration/fix_security_scan_statuses.rb,
lib/gitlab/background_migration/purge_stale_security_scans.rb,
lib/gitlab/background_migration/backfill_note_discussion_id.rb,
lib/gitlab/background_migration/backfill_releases_author_id.rb,
lib/gitlab/background_migration/sanitize_confidential_todos.rb,
lib/gitlab/background_migration/backfill_user_details_fields.rb,
lib/gitlab/background_migration/backfill_users_with_defaults.rb,
lib/gitlab/background_migration/migrate_pages_to_zip_storage.rb,
lib/gitlab/background_migration/populate_latest_pipeline_ids.rb,
lib/gitlab/background_migration/populate_projects_star_count.rb,
lib/gitlab/background_migration/backfill_project_import_level.rb,
lib/gitlab/background_migration/backfill_project_repositories.rb,
lib/gitlab/background_migration/backfill_resource_link_events.rb,
lib/gitlab/background_migration/backfill_snippet_repositories.rb,
lib/gitlab/background_migration/destroy_invalid_group_members.rb,
lib/gitlab/background_migration/backfill_compliance_violations.rb,
lib/gitlab/background_migration/backfill_integrations_type_new.rb,
lib/gitlab/background_migration/remove_self_managed_wiki_notes.rb,
lib/gitlab/background_migration/backfill_missing_ci_cd_settings.rb,
lib/gitlab/background_migration/destroy_invalid_project_members.rb,
lib/gitlab/background_migration/prune_stale_project_export_jobs.rb,
lib/gitlab/background_migration/set_correct_vulnerability_state.rb,
lib/gitlab/background_migration/third_recount_epic_cache_counts.rb,
lib/gitlab/background_migration/backfill_namespace_ldap_settings.rb,
lib/gitlab/background_migration/fix_first_mentioned_in_commit_at.rb,
lib/gitlab/background_migration/issues_internal_id_scope_updater.rb,
lib/gitlab/background_migration/second_recount_epic_cache_counts.rb,
lib/gitlab/background_migration/backfill_nuget_normalized_version.rb,
lib/gitlab/background_migration/batching_strategies/base_strategy.rb,
lib/gitlab/background_migration/project_namespaces/models/project.rb,
lib/gitlab/background_migration/backfill_project_namespace_details.rb,
lib/gitlab/background_migration/backfill_project_wiki_repositories.rb,
lib/gitlab/background_migration/fix_vulnerability_reads_has_issues.rb,
lib/gitlab/background_migration/migrate_approver_to_approval_rules.rb,
lib/gitlab/background_migration/migrate_requirements_to_work_items.rb,
lib/gitlab/background_migration/backfill_imported_issue_search_data.rb,
lib/gitlab/background_migration/backfill_prepared_at_merge_requests.rb,
lib/gitlab/background_migration/project_namespaces/models/namespace.rb,
lib/gitlab/background_migration/backfill_project_member_namespace_id.rb,
lib/gitlab/background_migration/backfill_project_namespace_on_issues.rb,
lib/gitlab/background_migration/fix_projects_without_project_feature.rb,
lib/gitlab/background_migration/migrate_job_artifact_registry_to_ssf.rb,
lib/gitlab/background_migration/backfill_work_item_type_id_for_issues.rb,
lib/gitlab/background_migration/create_compliance_standards_adherence.rb,
lib/gitlab/background_migration/delete_orphaned_packages_dependencies.rb,
lib/gitlab/background_migration/delete_orphans_approval_project_rules.rb,
lib/gitlab/background_migration/migrate_null_private_profile_to_false.rb,
lib/gitlab/background_migration/migrate_shared_vulnerability_scanners.rb,
lib/gitlab/background_migration/backfill_finding_id_in_vulnerabilities.rb,
lib/gitlab/background_migration/reset_status_on_container_repositories.rb,
lib/gitlab/background_migration/add_projects_emails_enabled_column_data.rb,
lib/gitlab/background_migration/backfill_design_management_repositories.rb,
lib/gitlab/background_migration/backfill_draft_status_on_merge_requests.rb,
lib/gitlab/background_migration/backfill_namespace_id_for_project_route.rb,
lib/gitlab/background_migration/backfill_user_preferences_with_defaults.rb,
lib/gitlab/background_migration/fix_projects_without_prometheus_service.rb,
lib/gitlab/background_migration/populate_vulnerability_dismissal_fields.rb,
lib/gitlab/background_migration/reset_duplicate_ci_runners_token_values.rb,
lib/gitlab/background_migration/backfill_iteration_cadence_id_for_boards.rb,
lib/gitlab/background_migration/backfill_workspace_personal_access_token.rb,
lib/gitlab/background_migration/delete_approval_rules_with_vulnerability.rb,
lib/gitlab/background_migration/fix_namespace_ids_of_vulnerability_reads.rb,
lib/gitlab/background_migration/migrate_links_for_vulnerability_findings.rb,
lib/gitlab/background_migration/migrate_shared_vulnerability_identifiers.rb,
lib/gitlab/background_migration/add_namespaces_emails_enabled_column_data.rb,
lib/gitlab/background_migration/remove_backfilled_job_artifacts_expire_at.rb,
lib/gitlab/background_migration/remove_invalid_deploy_access_level_groups.rb,
lib/gitlab/background_migration/rename_task_system_note_to_checklist_item.rb,
lib/gitlab/background_migration/backfill_vulnerability_reads_cluster_agent.rb,
lib/gitlab/background_migration/copy_column_using_background_migration_job.rb,
lib/gitlab/background_migration/populate_resolved_on_default_branch_column.rb,
lib/gitlab/background_migration/redis/backfill_project_pipeline_status_ttl.rb,
lib/gitlab/background_migration/backfill_cluster_agents_has_vulnerabilities.rb,
lib/gitlab/background_migration/backfill_member_namespace_for_group_members.rb,
lib/gitlab/background_migration/delete_orphaned_operational_vulnerabilities.rb,
lib/gitlab/background_migration/delete_orphans_approval_merge_request_rules.rb,
lib/gitlab/background_migration/mark_duplicate_npm_packages_for_destruction.rb,
lib/gitlab/background_migration/migrate_approver_to_approval_rules_in_batch.rb,
lib/gitlab/background_migration/nullify_last_error_from_project_mirror_data.rb,
lib/gitlab/background_migration/truncate_overlong_vulnerability_html_titles.rb,
lib/gitlab/background_migration/backfill_code_suggestions_namespace_settings.rb,
lib/gitlab/background_migration/backfill_namespace_id_of_vulnerability_reads.rb,
lib/gitlab/background_migration/migrate_evidences_for_vulnerability_findings.rb,
lib/gitlab/background_migration/reset_too_many_tags_skipped_registry_imports.rb,
lib/gitlab/background_migration/update_users_set_external_if_service_account.rb,
lib/gitlab/background_migration/backfill_integrations_enable_ssl_verification.rb,
lib/gitlab/background_migration/convert_credit_card_validation_data_to_hashes.rb,
lib/gitlab/background_migration/remove_project_group_link_with_missing_groups.rb,
lib/gitlab/background_migration/nullify_creator_id_column_of_orphaned_projects.rb,
lib/gitlab/background_migration/project_namespaces/backfill_project_namespaces.rb,
lib/gitlab/background_migration/migrate_remediations_for_vulnerability_findings.rb,
lib/gitlab/background_migration/backfill_dismissal_reason_in_vulnerability_reads.rb,
lib/gitlab/background_migration/backfill_missing_vulnerability_dismissal_details.rb,
lib/gitlab/background_migration/backfill_has_merge_request_of_vulnerability_reads.rb,
lib/gitlab/background_migration/batching_strategies/primary_key_batching_strategy.rb,
lib/gitlab/background_migration/migrate_approver_to_approval_rules_check_progress.rb,
lib/gitlab/background_migration/reset_duplicate_ci_runners_token_encrypted_values.rb,
lib/gitlab/background_migration/cleanup_personal_access_tokens_with_nil_expires_at.rb,
lib/gitlab/background_migration/delete_orphaned_transferred_project_approval_rules.rb,
lib/gitlab/background_migration/fix_incoherent_packages_size_on_project_statistics.rb,
lib/gitlab/background_migration/populate_denormalized_columns_for_sbom_occurrences.rb,
lib/gitlab/background_migration/update_ci_pipeline_artifacts_unknown_locked_status.rb,
lib/gitlab/background_migration/backfill_root_storage_statistics_fork_storage_sizes.rb,
lib/gitlab/background_migration/backfill_admin_mode_scope_for_personal_access_tokens.rb,
lib/gitlab/background_migration/backfill_default_branch_protection_namespace_setting.rb,
lib/gitlab/background_migration/backfill_project_statistics_container_repository_size.rb,
lib/gitlab/background_migration/fix_approval_project_rules_without_protected_branches.rb,
lib/gitlab/background_migration/update_jira_tracker_data_deployment_type_based_on_url.rb,
lib/gitlab/background_migration/backfill_project_feature_package_registry_access_level.rb,
lib/gitlab/background_migration/batching_strategies/dismissed_vulnerabilities_strategy.rb,
lib/gitlab/background_migration/batching_strategies/loose_index_scan_batching_strategy.rb,
lib/gitlab/background_migration/fix_allow_descendants_override_disabled_shared_runners.rb,
lib/gitlab/background_migration/backfill_project_statistics_storage_size_with_recent_size.rb,
lib/gitlab/background_migration/populate_operation_visibility_permissions_from_operations.rb,
lib/gitlab/background_migration/update_delayed_project_removal_to_null_for_user_namespaces.rb,
lib/gitlab/background_migration/populate_approval_project_rules_with_security_orchestration.rb,
lib/gitlab/background_migration/backfill_draft_status_on_merge_requests_with_corrected_regex.rb,
lib/gitlab/background_migration/backfill_uuid_conversion_column_in_vulnerability_occurrences.rb,
lib/gitlab/background_migration/backfill_project_statistics_storage_size_without_uploads_size.rb,
lib/gitlab/background_migration/disable_legacy_open_source_licence_for_recent_public_projects.rb,
lib/gitlab/background_migration/disable_legacy_open_source_license_for_inactive_public_projects.rb,
lib/gitlab/background_migration/disable_legacy_open_source_license_for_projects_less_than_one_mb.rb,
lib/gitlab/background_migration/set_legacy_open_source_license_available_for_non_public_projects.rb,
lib/gitlab/background_migration/disable_legacy_open_source_license_for_no_issues_no_repo_projects.rb,
lib/gitlab/background_migration/disable_legacy_open_source_license_for_projects_less_than_five_mb.rb,
lib/gitlab/background_migration/populate_approval_merge_request_rules_with_security_orchestration.rb,
lib/gitlab/background_migration/disable_legacy_open_source_license_for_one_member_no_repo_projects.rb,
lib/gitlab/background_migration/migrate_vulnerabilities_feedback_to_vulnerabilities_state_transition.rb,
lib/gitlab/background_migration/batching_strategies/backfill_project_namespace_per_group_batching_strategy.rb,
lib/gitlab/background_migration/backfill_project_statistics_storage_size_without_pipeline_artifacts_size_job.rb,
lib/gitlab/background_migration/batching_strategies/remove_backfilled_job_artifacts_expire_at_batching_strategy.rb,
lib/gitlab/background_migration/batching_strategies/backfill_vulnerability_reads_cluster_agent_batching_strategy.rb,
lib/gitlab/background_migration/batching_strategies/backfill_project_statistics_with_container_registry_size_batching_strategy.rb

Defined Under Namespace

Modules: BatchingStrategies, Mailers, ProjectNamespaces, Redis Classes: AddNamespacesEmailsEnabledColumnData, AddProjectsEmailsEnabledColumnData, BackfillAdminModeScopeForPersonalAccessTokens, BackfillClusterAgentsHasVulnerabilities, BackfillCodeSuggestionsNamespaceSettings, BackfillComplianceViolations, BackfillDefaultBranchProtectionNamespaceSetting, BackfillDesignManagementRepositories, BackfillDismissalReasonInVulnerabilityReads, BackfillDraftStatusOnMergeRequests, BackfillDraftStatusOnMergeRequestsWithCorrectedRegex, BackfillEnvironmentTiers, BackfillEpicCacheCounts, BackfillFindingIdInVulnerabilities, BackfillHasMergeRequestOfVulnerabilityReads, BackfillImportedIssueSearchData, BackfillIntegrationsEnableSslVerification, BackfillIntegrationsTypeNew, BackfillInternalOnNotes, BackfillIssueSearchData, BackfillIterationCadenceIdForBoards, BackfillMemberNamespaceForGroupMembers, BackfillMissingCiCdSettings, BackfillMissingVulnerabilityDismissalDetails, BackfillNamespaceDetails, BackfillNamespaceIdForProjectRoute, BackfillNamespaceIdOfVulnerabilityReads, BackfillNamespaceLdapSettings, BackfillNoteDiscussionId, BackfillNugetNormalizedVersion, BackfillPartitionedTable, BackfillPreparedAtMergeRequests, BackfillProjectFeaturePackageRegistryAccessLevel, BackfillProjectImportLevel, BackfillProjectMemberNamespaceId, BackfillProjectNamespaceDetails, BackfillProjectNamespaceOnIssues, BackfillProjectRepositories, BackfillProjectSettings, BackfillProjectStatisticsContainerRepositorySize, BackfillProjectStatisticsStorageSizeWithRecentSize, BackfillProjectStatisticsStorageSizeWithoutPipelineArtifactsSizeJob, BackfillProjectStatisticsStorageSizeWithoutUploadsSize, BackfillProjectWikiRepositories, BackfillReleasesAuthorId, BackfillResourceLinkEvents, BackfillRootStorageStatisticsForkStorageSizes, BackfillSnippetRepositories, BackfillTopicsTitle, BackfillUserDetailsFields, BackfillUserPreferencesWithDefaults, BackfillUsersWithDefaults, BackfillUuidConversionColumnInVulnerabilityOccurrences, BackfillVulnerabilityReadsClusterAgent, BackfillWorkItemTypeIdForIssues, BackfillWorkspacePersonalAccessToken, BaseJob, BatchedMigrationJob, CleanupOrphanedRoutes, CleanupPersonalAccessTokensWithNilExpiresAt, ConvertCreditCardValidationDataToHashes, CopyColumnUsingBackgroundMigrationJob, CreateComplianceStandardsAdherence, CreateSecuritySetting, CreateVulnerabilityLinks, DeleteApprovalRulesWithVulnerability, DeleteInvalidEpicIssues, DeleteOrphanedOperationalVulnerabilities, DeleteOrphanedPackagesDependencies, DeleteOrphanedTransferredProjectApprovalRules, DeleteOrphansApprovalMergeRequestRules, DeleteOrphansApprovalProjectRules, DestroyInvalidGroupMembers, DestroyInvalidMembers, DestroyInvalidProjectMembers, DisableLegacyOpenSourceLicenceForRecentPublicProjects, DisableLegacyOpenSourceLicenseForInactivePublicProjects, DisableLegacyOpenSourceLicenseForNoIssuesNoRepoProjects, DisableLegacyOpenSourceLicenseForOneMemberNoRepoProjects, DisableLegacyOpenSourceLicenseForProjectsLessThanFiveMb, DisableLegacyOpenSourceLicenseForProjectsLessThanOneMb, EncryptCiTriggerToken, ExpireOAuthTokens, FixAllowDescendantsOverrideDisabledSharedRunners, FixApprovalProjectRulesWithoutProtectedBranches, FixFirstMentionedInCommitAt, FixIncoherentPackagesSizeOnProjectStatistics, FixNamespaceIdsOfVulnerabilityReads, FixProjectsWithoutProjectFeature, FixProjectsWithoutPrometheusService, FixSecurityScanStatuses, FixVulnerabilityReadsHasIssues, IssuesInternalIdScopeUpdater, JobCoordinator, LegacyUploadMover, LegacyUploadsMigrator, Logger, MarkDuplicateNpmPackagesForDestruction, MigrateApproverToApprovalRules, MigrateApproverToApprovalRulesCheckProgress, MigrateApproverToApprovalRulesInBatch, MigrateEvidencesForVulnerabilityFindings, MigrateHumanUserType, MigrateJobArtifactRegistryToSsf, MigrateLinksForVulnerabilityFindings, MigrateNullPrivateProfileToFalse, MigratePagesToZipStorage, MigrateRemediationsForVulnerabilityFindings, MigrateRequirementsToWorkItems, MigrateSharedVulnerabilityIdentifiers, MigrateSharedVulnerabilityScanners, MigrateVulnerabilitiesFeedbackToVulnerabilitiesStateTransition, NullifyCreatorIdColumnOfOrphanedProjects, NullifyLastErrorFromProjectMirrorData, PopulateApprovalMergeRequestRulesWithSecurityOrchestration, PopulateApprovalProjectRulesWithSecurityOrchestration, PopulateDenormalizedColumnsForSbomOccurrences, PopulateLatestPipelineIds, PopulateOperationVisibilityPermissionsFromOperations, PopulateProjectsStarCount, PopulateResolvedOnDefaultBranchColumn, PopulateVulnerabilityDismissalFields, PruneStaleProjectExportJobs, PurgeStaleSecurityScans, ReExpireOAuthTokens, RecountEpicCacheCounts, RemoveBackfilledJobArtifactsExpireAt, RemoveInvalidDeployAccessLevelGroups, RemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindings, RemoveProjectGroupLinkWithMissingGroups, RemoveSelfManagedWikiNotes, RenameTaskSystemNoteToChecklistItem, ResetDuplicateCiRunnersTokenEncryptedValues, ResetDuplicateCiRunnersTokenValues, ResetStatusOnContainerRepositories, ResetTooManyTagsSkippedRegistryImports, Route, SanitizeConfidentialTodos, SecondRecountEpicCacheCounts, SetCorrectVulnerabilityState, SetLegacyOpenSourceLicenseAvailableForNonPublicProjects, SyncScanResultPolicies, ThirdRecountEpicCacheCounts, TruncateOverlongVulnerabilityHtmlTitles, UpdateCiPipelineArtifactsUnknownLockedStatus, UpdateDelayedProjectRemovalToNullForUserNamespaces, UpdateJiraTrackerDataDeploymentTypeBasedOnUrl, UpdateUsersSetExternalIfServiceAccount

Constant Summary collapse

DEFAULT_TRACKING_DATABASE =
Gitlab::Database::MAIN_DATABASE_NAME

Class Method Summary collapse

Class Method Details

.coordinator_for_database(database) ⇒ Object



7
8
9
# File 'lib/gitlab/background_migration.rb', line 7

def self.coordinator_for_database(database)
  JobCoordinator.for_tracking_database(database)
end

.exists?(migration_class, additional_queues = [], database: DEFAULT_TRACKING_DATABASE) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/gitlab/background_migration.rb', line 44

def self.exists?(migration_class, additional_queues = [], database: DEFAULT_TRACKING_DATABASE)
  coordinator_for_database(database).exists?(migration_class, additional_queues) # rubocop:disable CodeReuse/ActiveRecord
end

.perform(class_name, arguments, database: DEFAULT_TRACKING_DATABASE) ⇒ Object

Performs a background migration.

class_name - The name of the background migration class as defined in the

Gitlab::BackgroundMigration namespace.

arguments - The arguments to pass to the background migration’s “perform”

method.

database - tracking database this migration executes against



40
41
42
# File 'lib/gitlab/background_migration.rb', line 40

def self.perform(class_name, arguments, database: DEFAULT_TRACKING_DATABASE)
  coordinator_for_database(database).perform(class_name, arguments)
end

.queue(database: DEFAULT_TRACKING_DATABASE) ⇒ Object



11
12
13
# File 'lib/gitlab/background_migration.rb', line 11

def self.queue(database: DEFAULT_TRACKING_DATABASE)
  coordinator_for_database(database).queue
end

.remaining(database: DEFAULT_TRACKING_DATABASE) ⇒ Object



48
49
50
# File 'lib/gitlab/background_migration.rb', line 48

def self.remaining(database: DEFAULT_TRACKING_DATABASE)
  coordinator_for_database(database).remaining
end

.steal(steal_class, retry_dead_jobs: false, database: DEFAULT_TRACKING_DATABASE, &block) ⇒ Object

Begins stealing jobs from the background migrations queue, blocking the caller until all jobs have been completed.

When a migration raises a StandardError it is going to retry up to three times, for example, to recover from a deadlock.

When Exception is being raised, it enqueues the migration again, and re-raises the exception.

steal_class - The name of the class for which to steal jobs. retry_dead_jobs - Flag to control whether jobs in Sidekiq::RetrySet or Sidekiq::DeadSet are retried. database - tracking database this migration executes against



27
28
29
# File 'lib/gitlab/background_migration.rb', line 27

def self.steal(steal_class, retry_dead_jobs: false, database: DEFAULT_TRACKING_DATABASE, &block)
  coordinator_for_database(database).steal(steal_class, retry_dead_jobs: retry_dead_jobs, &block)
end