diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-07-04 16:06:30 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-07-10 09:43:58 -0300 |
commit | 4455904bc154f1a36cedeea574bb0f454f92a9e9 (patch) | |
tree | 7484b5e155ffb386cf87684f76d3a8bfe98c4c8d /db | |
parent | e66535e8407ccb8dd229fefdce817902a364f58a (diff) | |
download | gitlab-ce-4455904bc154f1a36cedeea574bb0f454f92a9e9.tar.gz |
Add 1000 files per minute deletion ratio on scheduler
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb b/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb index 92950c1eec1..df30991737c 100644 --- a/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb +++ b/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb @@ -1,52 +1,20 @@ class EnqueueDeleteDiffFilesWorkers < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - class MergeRequestDiff < ActiveRecord::Base - self.table_name = 'merge_request_diffs' - - belongs_to :merge_request - - include EachBatch - end - DOWNTIME = false - BATCH_SIZE = 1000 SCHEDULER = 'ScheduleDiffFilesDeletion'.freeze TMP_INDEX = 'tmp_partial_diff_id_with_files_index'.freeze disable_ddl_transaction! def up - # We add temporary index, to make iteration over batches more performant. - # Conditional here is to avoid the need of doing that in a separate - # migration file to make this operation idempotent. - # unless index_exists_by_name?(:merge_request_diffs, TMP_INDEX) add_concurrent_index(:merge_request_diffs, :id, where: "(state NOT IN ('without_files', 'empty'))", name: TMP_INDEX) end - - diffs_with_files = MergeRequestDiff.where.not(state: ['without_files', 'empty']) - - # explain (analyze, buffers) example for the iteration: - # - # Index Only Scan using tmp_index_20013 on merge_request_diffs (cost=0.43..1630.19 rows=60567 width=4) (actual time=0.047..9.572 rows=56976 loops=1) - # Index Cond: ((id >= 764586) AND (id < 835298)) - # Heap Fetches: 8 - # Buffers: shared hit=18188 - # Planning time: 0.752 ms - # Execution time: 12.430 ms - # - diffs_with_files.each_batch(of: BATCH_SIZE) do |relation, scheduler_index| - ids = relation.pluck(:id).map { |id| [id] } - - BackgroundMigrationWorker.perform_async(SCHEDULER, [ids, scheduler_index]) - end - - # We remove temporary index, because it is not required during standard - # operations and runtime. - # - remove_concurrent_index_by_name(:merge_request_diffs, TMP_INDEX) + # We keep the index since this will be used async. + # Ideally we should remove it in an upcoming release. + BackgroundMigrationWorker.perform_async(SCHEDULER) end def down |