diff --git a/ee/elastic/docs/20250226143000_reindex_work_items_to_backfill_notes.yml b/ee/elastic/docs/20250226143000_reindex_work_items_to_backfill_notes.yml new file mode 100644 index 0000000000000000000000000000000000000000..3bc61a9bda729292d8257a4c26524292fecfb81e --- /dev/null +++ b/ee/elastic/docs/20250226143000_reindex_work_items_to_backfill_notes.yml @@ -0,0 +1,12 @@ +--- +name: ReindexWorkItemsToBackfillNotes +version: '20250226143000' +description: Reindex all work items to backfill notes +group: group::global search +milestone: '17.10' +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/182950 +obsolete: false +marked_obsolete_by_url: +marked_obsolete_in_milestone: +skippable: true +skip_condition: 'Only run on GitLab.com' \ No newline at end of file diff --git a/ee/elastic/migrate/20250226143000_reindex_work_items_to_backfill_notes.rb b/ee/elastic/migrate/20250226143000_reindex_work_items_to_backfill_notes.rb new file mode 100644 index 0000000000000000000000000000000000000000..48b0cede3cb649161d89d59c52c5b8dbbd3f0358 --- /dev/null +++ b/ee/elastic/migrate/20250226143000_reindex_work_items_to_backfill_notes.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class ReindexWorkItemsToBackfillNotes < Elastic::Migration + include Search::Elastic::MigrationReindexBasedOnSchemaVersion + extend ::Gitlab::Utils::Override + + skip_if -> { !::Gitlab::Saas.feature_available?(:advanced_search) } + + batched! + batch_size 9_000 + throttle_delay 1.minute + + DOCUMENT_TYPE = WorkItem + NEW_SCHEMA_VERSION = 25_09 + UPDATE_BATCH_SIZE = 100 + + private + + override :index_name + def index_name + Search::Elastic::Types::WorkItem.index_name + end +end diff --git a/ee/lib/search/elastic/references/work_item.rb b/ee/lib/search/elastic/references/work_item.rb index cf7b5162a5adc195d5e44ce737a4d10b5e917f43..6aa2f5fa5e252dba4ccc54c964c7f7d2297bf174 100644 --- a/ee/lib/search/elastic/references/work_item.rb +++ b/ee/lib/search/elastic/references/work_item.rb @@ -6,7 +6,7 @@ module References class WorkItem < Reference include Search::Elastic::Concerns::DatabaseReference - SCHEMA_VERSION = 25_08 + SCHEMA_VERSION = 25_09 NOTES_MAXIMUM_BYTES = 512.kilobytes override :serialize diff --git a/ee/spec/elastic/migrate/20250226143000_reindex_work_items_to_backfill_notes_spec.rb b/ee/spec/elastic/migrate/20250226143000_reindex_work_items_to_backfill_notes_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..b73d894c9b4fb6259c786d003161dfc974847429 --- /dev/null +++ b/ee/spec/elastic/migrate/20250226143000_reindex_work_items_to_backfill_notes_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' +require File.expand_path('ee/elastic/migrate/20250226143000_reindex_work_items_to_backfill_notes.rb') + +RSpec.describe ReindexWorkItemsToBackfillNotes, :elastic_delete_by_query, :sidekiq_inline, feature_category: :global_search do + let(:version) { 20250226143000 } + + describe 'skip_if setting' do + subject(:migration) { described_class.new(version) } + + context 'when on Saas', :saas do + it { expect(migration.skip_migration?).to be false } + end + + context 'when not on Saas' do + it { expect(migration.skip_migration?).to be true } + end + end + + include_examples 'migration reindex based on schema_version' do + let(:index_name) { ::Search::Elastic::Types::WorkItem.index_name } + let(:objects) { create_list(:work_item, 3) } + let(:expected_throttle_delay) { 1.minute } + let(:expected_batch_size) { 9_000 } + end +end