Commit e2aa3325 authored by Felipe Artur's avatar Felipe Artur

Improve batch size

parent 362d56e6
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# == IssuableStates concern # == IssuableStates concern
# #
# Defines statuses shared by issuables which are persisted on state column # Defines states shared by issuables which are persisted on state_id column
# using the state machine. # using the state machine.
# #
# Used by EE::Epic, Issue and MergeRequest # Used by EE::Epic, Issue and MergeRequest
...@@ -14,10 +14,6 @@ module IssuableStates ...@@ -14,10 +14,6 @@ module IssuableStates
# Check MergeRequest::AVAILABLE_STATES # Check MergeRequest::AVAILABLE_STATES
AVAILABLE_STATES = { opened: 1, closed: 2 }.freeze AVAILABLE_STATES = { opened: 1, closed: 2 }.freeze
included do
before_save :set_state_id
end
class_methods do class_methods do
def states def states
@states ||= OpenStruct.new(self::AVAILABLE_STATES) @states ||= OpenStruct.new(self::AVAILABLE_STATES)
...@@ -26,7 +22,11 @@ module IssuableStates ...@@ -26,7 +22,11 @@ module IssuableStates
# The state:string column is being migrated to state_id:integer column # The state:string column is being migrated to state_id:integer column
# This is a temporary hook to populate state_id column with new values # This is a temporary hook to populate state_id column with new values
# and can be removed after the complete migration is done. # and can be removed after the state column is removed.
included do
before_save :set_state_id
end
def set_state_id def set_state_id
return if state.nil? || state.empty? return if state.nil? || state.empty?
......
...@@ -22,7 +22,6 @@ class MergeRequest < ActiveRecord::Base ...@@ -22,7 +22,6 @@ class MergeRequest < ActiveRecord::Base
self.reactive_cache_lifetime = 10.minutes self.reactive_cache_lifetime = 10.minutes
SORTING_PREFERENCE_FIELD = :merge_requests_sort SORTING_PREFERENCE_FIELD = :merge_requests_sort
MERGE_REQUEST_STATES =
AVAILABLE_STATES = AVAILABLE_STATES.merge(merged: 3, locked: 4).freeze AVAILABLE_STATES = AVAILABLE_STATES.merge(merged: 3, locked: 4).freeze
ignore_column :locked_at, ignore_column :locked_at,
......
...@@ -5,10 +5,12 @@ class AddStateIdToIssuables < ActiveRecord::Migration[5.0] ...@@ -5,10 +5,12 @@ class AddStateIdToIssuables < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
MIGRATION = 'SyncIssuablesStateId'.freeze MIGRATION = 'SyncIssuablesStateId'.freeze
# TODO - find out how many issues and merge requests in production # 2019-02-12 Gitlab.com issuable numbers
# to adapt the batch size and delay interval # issues count: 13587305
# Keep in mind that the migration will be scheduled for issues and merge requests. # merge requests count: 18925274
BATCH_SIZE = 5000 # Using this 50000 as batch size should take around 13 hours
# to migrate both issues and merge requests
BATCH_SIZE = 50000
DELAY_INTERVAL = 5.minutes.to_i DELAY_INTERVAL = 5.minutes.to_i
class Issue < ActiveRecord::Base class Issue < ActiveRecord::Base
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment