From 9ae94dedc0c92d52707f464ddd8d1dad7f052d6a Mon Sep 17 00:00:00 2001 From: Maxime Orefice Date: Thu, 12 Jan 2023 16:02:43 +0100 Subject: [PATCH 1/2] Add tmp indexes for CI partitioning - 2 Changelog: added --- ...112144946_add_tmp_index_to_ci_build_need.rb | 18 ++++++++++++++++++ ...26_add_tmp_index_to_ci_pipeline_variable.rb | 18 ++++++++++++++++++ ...add_tmp_index_to_ci_build_report_results.rb | 18 ++++++++++++++++++ db/schema_migrations/20230112144946 | 1 + db/schema_migrations/20230112145326 | 1 + db/schema_migrations/20230117092947 | 1 + 6 files changed, 57 insertions(+) create mode 100644 db/post_migrate/20230112144946_add_tmp_index_to_ci_build_need.rb create mode 100644 db/post_migrate/20230112145326_add_tmp_index_to_ci_pipeline_variable.rb create mode 100644 db/post_migrate/20230117092947_add_tmp_index_to_ci_build_report_results.rb create mode 100644 db/schema_migrations/20230112144946 create mode 100644 db/schema_migrations/20230112145326 create mode 100644 db/schema_migrations/20230117092947 diff --git a/db/post_migrate/20230112144946_add_tmp_index_to_ci_build_need.rb b/db/post_migrate/20230112144946_add_tmp_index_to_ci_build_need.rb new file mode 100644 index 00000000000000..d7c3e8a43df593 --- /dev/null +++ b/db/post_migrate/20230112144946_add_tmp_index_to_ci_build_need.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddTmpIndexToCiBuildNeed < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = :tmp_index_ci_build_needs_on_partition_id_and_id + TABLE_NAME = :ci_build_needs + + def up + return unless Gitlab.com? + + prepare_async_index(TABLE_NAME, [:partition_id, :id], where: 'partition_id = 101', name: INDEX_NAME) + end + + def down + unprepare_async_index(TABLE_NAME, INDEX_NAME) + end +end diff --git a/db/post_migrate/20230112145326_add_tmp_index_to_ci_pipeline_variable.rb b/db/post_migrate/20230112145326_add_tmp_index_to_ci_pipeline_variable.rb new file mode 100644 index 00000000000000..4096a235db35ec --- /dev/null +++ b/db/post_migrate/20230112145326_add_tmp_index_to_ci_pipeline_variable.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddTmpIndexToCiPipelineVariable < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = :tmp_index_ci_pipeline_variables_on_partition_id_and_id + TABLE_NAME = :ci_pipeline_variables + + def up + return unless Gitlab.com? + + prepare_async_index(TABLE_NAME, [:partition_id, :id], where: 'partition_id = 101', name: INDEX_NAME) + end + + def down + unprepare_async_index(TABLE_NAME, INDEX_NAME) + end +end diff --git a/db/post_migrate/20230117092947_add_tmp_index_to_ci_build_report_results.rb b/db/post_migrate/20230117092947_add_tmp_index_to_ci_build_report_results.rb new file mode 100644 index 00000000000000..bb01e5e208b31e --- /dev/null +++ b/db/post_migrate/20230117092947_add_tmp_index_to_ci_build_report_results.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddTmpIndexToCiBuildReportResults < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = :tmp_index_ci_build_report_results_on_partition_id_and_id + TABLE_NAME = :ci_build_report_results + + def up + return unless Gitlab.com? + + prepare_async_index(TABLE_NAME, [:partition_id, :id], where: 'partition_id = 101', name: INDEX_NAME) + end + + def down + unprepare_async_index(TABLE_NAME, INDEX_NAME) + end +end diff --git a/db/schema_migrations/20230112144946 b/db/schema_migrations/20230112144946 new file mode 100644 index 00000000000000..e9e307791f5f94 --- /dev/null +++ b/db/schema_migrations/20230112144946 @@ -0,0 +1 @@ +a2cb76b2138b3edc014c01c4b130fcd58bf81a10c68c897376f5bf8d69d5a660 \ No newline at end of file diff --git a/db/schema_migrations/20230112145326 b/db/schema_migrations/20230112145326 new file mode 100644 index 00000000000000..1878bebba663a7 --- /dev/null +++ b/db/schema_migrations/20230112145326 @@ -0,0 +1 @@ +97a52b54895ff5f5ea3c2dac6148c8d8110081bffe9064c50547b776ec56e78a \ No newline at end of file diff --git a/db/schema_migrations/20230117092947 b/db/schema_migrations/20230117092947 new file mode 100644 index 00000000000000..4eeca7e352629f --- /dev/null +++ b/db/schema_migrations/20230117092947 @@ -0,0 +1 @@ +775eb98fc81524f667cfab4dfdcee9bd668143c7286011dd1f0d40f87fc06ab0 \ No newline at end of file -- GitLab From 4cba472af15a8e5be86473e5c625995dbfcb2733 Mon Sep 17 00:00:00 2001 From: Maxime Orefice Date: Tue, 17 Jan 2023 15:37:16 +0100 Subject: [PATCH 2/2] Apply code review feedback --- .../20230112144946_add_tmp_index_to_ci_build_need.rb | 4 +++- .../20230112145326_add_tmp_index_to_ci_pipeline_variable.rb | 4 +++- ...20230117092947_add_tmp_index_to_ci_build_report_results.rb | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/db/post_migrate/20230112144946_add_tmp_index_to_ci_build_need.rb b/db/post_migrate/20230112144946_add_tmp_index_to_ci_build_need.rb index d7c3e8a43df593..d1e0ae6665f08a 100644 --- a/db/post_migrate/20230112144946_add_tmp_index_to_ci_build_need.rb +++ b/db/post_migrate/20230112144946_add_tmp_index_to_ci_build_need.rb @@ -13,6 +13,8 @@ def up end def down - unprepare_async_index(TABLE_NAME, INDEX_NAME) + return unless Gitlab.com? + + unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) end end diff --git a/db/post_migrate/20230112145326_add_tmp_index_to_ci_pipeline_variable.rb b/db/post_migrate/20230112145326_add_tmp_index_to_ci_pipeline_variable.rb index 4096a235db35ec..920b70765cc941 100644 --- a/db/post_migrate/20230112145326_add_tmp_index_to_ci_pipeline_variable.rb +++ b/db/post_migrate/20230112145326_add_tmp_index_to_ci_pipeline_variable.rb @@ -13,6 +13,8 @@ def up end def down - unprepare_async_index(TABLE_NAME, INDEX_NAME) + return unless Gitlab.com? + + unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) end end diff --git a/db/post_migrate/20230117092947_add_tmp_index_to_ci_build_report_results.rb b/db/post_migrate/20230117092947_add_tmp_index_to_ci_build_report_results.rb index bb01e5e208b31e..a116562e9ec315 100644 --- a/db/post_migrate/20230117092947_add_tmp_index_to_ci_build_report_results.rb +++ b/db/post_migrate/20230117092947_add_tmp_index_to_ci_build_report_results.rb @@ -13,6 +13,8 @@ def up end def down - unprepare_async_index(TABLE_NAME, INDEX_NAME) + return unless Gitlab.com? + + unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) end end -- GitLab