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/migrate_u2f_webauthn.rb,
lib/gitlab/background_migration/backfill_topics_title.rb,
lib/gitlab/background_migration/batched_migration_job.rb,
lib/gitlab/background_migration/backfill_group_features.rb,
lib/gitlab/background_migration/backfill_user_namespace.rb,
lib/gitlab/background_migration/create_security_setting.rb,
lib/gitlab/background_migration/legacy_uploads_migrator.rb,
lib/gitlab/background_migration/mailers/unconfirm_mailer.rb,
lib/gitlab/background_migration/backfill_project_settings.rb,
lib/gitlab/background_migration/drop_invalid_remediations.rb,
lib/gitlab/background_migration/backfill_ci_queuing_tables.rb,
lib/gitlab/background_migration/backfill_issue_search_data.rb,
lib/gitlab/background_migration/update_timelogs_project_id.rb,
lib/gitlab/background_migration/backfill_ci_project_mirrors.rb,
lib/gitlab/background_migration/delete_orphaned_deployments.rb,
lib/gitlab/background_migration/encrypt_static_object_token.rb,
lib/gitlab/background_migration/merge_topics_with_same_name.rb,
lib/gitlab/background_migration/fix_incorrect_max_seats_used.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_vulnerability_reads.rb,
lib/gitlab/background_migration/backfill_artifact_expiry_date.rb,
lib/gitlab/background_migration/backfill_ci_namespace_mirrors.rb,
lib/gitlab/background_migration/backfill_project_repositories.rb,
lib/gitlab/background_migration/backfill_snippet_repositories.rb,
lib/gitlab/background_migration/populate_namespace_statistics.rb,
lib/gitlab/background_migration/update_timelogs_null_spent_at.rb,
lib/gitlab/background_migration/backfill_integrations_type_new.rb,
lib/gitlab/background_migration/drop_invalid_security_findings.rb,
lib/gitlab/background_migration/encrypt_integration_properties.rb,
lib/gitlab/background_migration/populate_test_reports_issue_id.rb,
lib/gitlab/background_migration/backfill_projects_with_coverage.rb,
lib/gitlab/background_migration/backfill_upvotes_count_on_issues.rb,
lib/gitlab/background_migration/fix_first_mentioned_in_commit_at.rb,
lib/gitlab/background_migration/batching_strategies/base_strategy.rb,
lib/gitlab/background_migration/project_namespaces/models/project.rb,
lib/gitlab/background_migration/remove_all_trace_expiration_dates.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/remove_vulnerability_finding_links.rb,
lib/gitlab/background_migration/fix_duplicate_project_name_and_path.rb,
lib/gitlab/background_migration/fix_merge_request_diff_commit_users.rb,
lib/gitlab/background_migration/project_namespaces/models/namespace.rb,
lib/gitlab/background_migration/cleanup_draft_data_from_faulty_regex.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/populate_uuids_for_security_findings.rb,
lib/gitlab/background_migration/backfill_work_item_type_id_for_issues.rb,
lib/gitlab/background_migration/cleanup_orphaned_lfs_objects_projects.rb,
lib/gitlab/background_migration/migrate_null_private_profile_to_false.rb,
lib/gitlab/background_migration/nullify_orphan_runner_id_on_ci_builds.rb,
lib/gitlab/background_migration/backfill_jira_tracker_deployment_type2.rb,
lib/gitlab/background_migration/backfill_namespace_traversal_ids_roots.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/fix_projects_without_prometheus_service.rb,
lib/gitlab/background_migration/migrate_merge_request_diff_commit_users.rb,
lib/gitlab/background_migration/backfill_iteration_cadence_id_for_boards.rb,
lib/gitlab/background_migration/copy_ci_builds_columns_to_security_scans.rb,
lib/gitlab/background_migration/populate_status_column_of_security_scans.rb,
lib/gitlab/background_migration/backfill_namespace_id_for_namespace_route.rb,
lib/gitlab/background_migration/backfill_namespace_traversal_ids_children.rb,
lib/gitlab/background_migration/update_vulnerability_occurrences_location.rb,
lib/gitlab/background_migration/copy_column_using_background_migration_job.rb,
lib/gitlab/background_migration/extract_project_topics_into_separate_table.rb,
lib/gitlab/background_migration/populate_resolved_on_default_branch_column.rb,
lib/gitlab/background_migration/populate_topics_non_private_projects_count.rb,
lib/gitlab/background_migration/populate_topics_total_projects_count_cache.rb,
lib/gitlab/background_migration/backfill_member_namespace_for_group_members.rb,
lib/gitlab/background_migration/migrate_approver_to_approval_rules_in_batch.rb,
lib/gitlab/background_migration/populate_container_repository_migration_plan.rb,
lib/gitlab/background_migration/add_primary_email_to_emails_if_user_confirmed.rb,
lib/gitlab/background_migration/backfill_integrations_enable_ssl_verification.rb,
lib/gitlab/background_migration/migrate_shimo_confluence_integration_category.rb,
lib/gitlab/background_migration/steal_migrate_merge_request_diff_commit_users.rb,
lib/gitlab/background_migration/project_namespaces/backfill_project_namespaces.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/move_container_registry_enabled_to_project_feature.rb,
lib/gitlab/background_migration/reset_duplicate_ci_runners_token_values_on_projects.rb,
lib/gitlab/background_migration/migrate_project_taggings_context_from_tags_to_topics.rb,
lib/gitlab/background_migration/migrate_personal_namespace_project_maintainer_to_owner.rb,
lib/gitlab/background_migration/update_users_where_two_factor_auth_required_from_group.rb,
lib/gitlab/background_migration/disable_expiration_policies_linked_to_no_container_images.rb,
lib/gitlab/background_migration/fix_vulnerability_occurrences_with_hashes_as_raw_metadata.rb,
lib/gitlab/background_migration/recalculate_vulnerability_finding_signatures_for_findings.rb,
lib/gitlab/background_migration/reset_duplicate_ci_runners_token_encrypted_values_on_projects.rb,
lib/gitlab/background_migration/batching_strategies/backfill_issue_work_item_type_batching_strategy.rb,
lib/gitlab/background_migration/batching_strategies/backfill_project_namespace_per_group_batching_strategy.rb
Defined Under Namespace
Modules: BatchingStrategies, Mailers, ProjectNamespaces Classes: AddPrimaryEmailToEmailsIfUserConfirmed, BackfillArtifactExpiryDate, BackfillCiNamespaceMirrors, BackfillCiProjectMirrors, BackfillCiQueuingTables, BackfillDraftStatusOnMergeRequests, BackfillGroupFeatures, BackfillIntegrationsEnableSslVerification, BackfillIntegrationsTypeNew, BackfillIssueSearchData, BackfillIterationCadenceIdForBoards, BackfillJiraTrackerDeploymentType2, BackfillMemberNamespaceForGroupMembers, BackfillNamespaceIdForNamespaceRoute, BackfillNamespaceIdForProjectRoute, BackfillNamespaceTraversalIdsChildren, BackfillNamespaceTraversalIdsRoots, BackfillProjectRepositories, BackfillProjectSettings, BackfillProjectsWithCoverage, BackfillSnippetRepositories, BackfillTopicsTitle, BackfillUpvotesCountOnIssues, BackfillUserNamespace, BackfillWorkItemTypeIdForIssues, BaseJob, BatchedMigrationJob, CleanupDraftDataFromFaultyRegex, CleanupOrphanedLfsObjectsProjects, CopyCiBuildsColumnsToSecurityScans, CopyColumnUsingBackgroundMigrationJob, CreateSecuritySetting, DeleteOrphanedDeployments, DisableExpirationPoliciesLinkedToNoContainerImages, DropInvalidRemediations, DropInvalidSecurityFindings, DropInvalidVulnerabilities, EncryptIntegrationProperties, EncryptStaticObjectToken, ExtractProjectTopicsIntoSeparateTable, FixDuplicateProjectNameAndPath, FixFirstMentionedInCommitAt, FixIncorrectMaxSeatsUsed, FixMergeRequestDiffCommitUsers, FixProjectsWithoutProjectFeature, FixProjectsWithoutPrometheusService, FixVulnerabilityOccurrencesWithHashesAsRawMetadata, JobCoordinator, LegacyUploadMover, LegacyUploadsMigrator, Logger, MergeTopicsWithSameName, MigrateApproverToApprovalRules, MigrateApproverToApprovalRulesCheckProgress, MigrateApproverToApprovalRulesInBatch, MigrateJobArtifactRegistryToSsf, MigrateMergeRequestDiffCommitUsers, MigrateNullPrivateProfileToFalse, MigratePagesToZipStorage, MigratePersonalNamespaceProjectMaintainerToOwner, MigrateProjectTaggingsContextFromTagsToTopics, MigrateRequirementsToWorkItems, MigrateShimoConfluenceIntegrationCategory, MigrateU2fWebauthn, MoveContainerRegistryEnabledToProjectFeature, NullifyOrphanRunnerIdOnCiBuilds, PopulateContainerRepositoryMigrationPlan, PopulateLatestPipelineIds, PopulateNamespaceStatistics, PopulateResolvedOnDefaultBranchColumn, PopulateStatusColumnOfSecurityScans, PopulateTestReportsIssueId, PopulateTopicsNonPrivateProjectsCount, PopulateTopicsTotalProjectsCountCache, PopulateUuidsForSecurityFindings, PopulateVulnerabilityReads, RecalculateVulnerabilitiesOccurrencesUuid, RecalculateVulnerabilityFindingSignaturesForFindings, RemoveAllTraceExpirationDates, RemoveDuplicateVulnerabilitiesFindings, RemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindings, RemoveVulnerabilityFindingLinks, ResetDuplicateCiRunnersTokenEncryptedValuesOnProjects, ResetDuplicateCiRunnersTokenValuesOnProjects, StealMigrateMergeRequestDiffCommitUsers, UpdateJiraTrackerDataDeploymentTypeBasedOnUrl, UpdateTimelogsNullSpentAt, UpdateTimelogsProjectId, UpdateUsersWhereTwoFactorAuthRequiredFromGroup, UpdateVulnerabilityOccurrencesLocation
Constant Summary collapse
- DEFAULT_TRACKING_DATABASE =
Gitlab::Database::MAIN_DATABASE_NAME
- SUB_BATCH_SIZE =
1_000
- BATCH_SIZE =
1000
Class Method Summary collapse
- .coordinator_for_database(database) ⇒ Object
- .exists?(migration_class, additional_queues = [], database: DEFAULT_TRACKING_DATABASE) ⇒ Boolean
-
.perform(class_name, arguments, database: DEFAULT_TRACKING_DATABASE) ⇒ Object
Performs a background migration.
- .queue(database: DEFAULT_TRACKING_DATABASE) ⇒ Object
- .remaining(database: DEFAULT_TRACKING_DATABASE) ⇒ Object
-
.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.
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
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 |