Draft: Remove backfill_ci_finished_builds BBM and mode-split logic

What does this MR do and why?

Closes #592894.

Cleans up the BackfillCiFinishedBuildsToClickHouse BBM and related code after the BBM was finalized in 19.0. Per the batched background migration cleanup guidelines:

Once a batched background migration has completed, is finalized and has not been re-queued, the migration code and its associated tests can be deleted after the next required stop following the finalization.

19.2 is the next required stop after 19.0, so this is the correct release for cleanup.

What this MR removes

1. BBM code and YAML

  • lib/gitlab/background_migration/backfill_ci_finished_builds_to_click_house.rb
  • ee/lib/ee/gitlab/background_migration/backfill_ci_finished_builds_to_click_house.rb
  • ee/spec/lib/ee/gitlab/background_migration/backfill_ci_finished_builds_to_click_house_spec.rb
  • db/docs/batched_background_migrations/backfill_ci_finished_builds_to_click_house.yml

2. Enqueue and finalize migrations + schema_migrations

  • db/post_migrate/20260204083514_queue_backfill_ci_finished_builds_to_click_house.rb
  • db/post_migrate/20260413072219_finalize_backfill_ci_finished_builds_to_click_house.rb
  • db/schema_migrations/20260204083514
  • db/schema_migrations/20260413072219
  • spec/migrations/20260204083514_queue_backfill_ci_finished_builds_to_click_house_spec.rb

3. CiFinishedBuildsConsistencyHelper and all backfill_in_progress? usage

  • lib/click_house/migration_support/ci_finished_builds_consistency_helper.rb
  • spec/lib/click_house/migration_support/ci_finished_builds_consistency_helper_spec.rb
  • backfill_in_progress? call in ee/app/workers/click_house/ci_finished_builds_sync_cron_worker.rb
  • backfill_in_progress? call in lib/ci/job_analytics/query_builder.rb — now always uses FinishedBuildsFinder
  • Backfill stubs in spec/requests/api/graphql/project/job_analytics_spec.rb

4. Backfill mode-split changes from !226068 (merged)

  • recent / backfill worker split in ci_finished_builds_sync_cron_worker.rb
  • mode parameter from ci_finished_builds_sync_service.rb (incl. MODES, RECENT_THRESHOLD, apply_mode_filter, conditional ordering, mode in service payload, lock-key mode component)
  • order_by_build_finished_at scope from finished_build_ch_sync_event.rb
  • All related specs

Notes

  • Feature flag ci_finished_builds_ch_sync_mode_split is already gone — it was removed in master in commit 8840b20f. No action needed on this part of the issue task list.
  • Sidekiq backward compatibility: CiFinishedBuildsSyncWorker#perform keeps a deprecated _mode = nil argument (ignored) for one release per the Sidekiq compatibility guidelines. In-flight jobs scheduled by the old 3-arg cron path will still execute. The argument can be fully removed in 19.3.
  • Follow-up: ClickHouse::Finders::Ci::FinishedBuildsDeduplicatedFinder was only used by the now-removed backfill_in_progress? branch in the query builder. It is now unused in production code and can be removed in a separate cleanup MR.

Sibling MR

!241619 (merged) removes the temporary index_ci_finished_build_ch_sync_events_on_mode_filter index from p_ci_finished_build_ch_sync_events.

The two MRs are independent and can be merged in any order. After both merge, the mode-split feature is fully removed.

Verification

$ bundle exec rspec \
    ee/spec/models/ci/finished_build_ch_sync_event_spec.rb \
    ee/spec/services/click_house/data_ingestion/ci_finished_builds_sync_service_spec.rb \
    ee/spec/workers/click_house/ci_finished_builds_sync_cron_worker_spec.rb \
    ee/spec/workers/click_house/ci_finished_builds_sync_worker_spec.rb \
    spec/lib/ci/job_analytics/query_builder_spec.rb \
    spec/requests/api/graphql/project/job_analytics_spec.rb
...
174 examples, 0 failures

Rubocop is clean on all touched files.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Narendran

Merge request reports

Loading
Loading